Create Useful Power BI dashboards with Deepsseek – DeepSeek R1 is a groundbreaking artificial intelligence model developed by the Chinese company DeepSeek. Launched in November 2024, it has quickly garnered attention for its advanced capabilities and cost-effective development. Notably, DeepSeek R1 was created with a budget of approximately $5.58 million, a fraction of the cost incurred by other leading AI models. Despite its economical development, it delivers performance comparable to top-tier models like OpenAI’s GPT-4.
One of the standout features of DeepSeek R1 is its open-source nature, released under the permissive MIT license. This openness encourages global experimentation and adaptation, potentially democratizing access to advanced AI technology.
However, the emergence of DeepSeek R1 has also raised concerns regarding data privacy and security. Experts caution that the Chinese government could potentially leverage the AI system for foreign influence operations, disinformation campaigns, surveillance, and the development of cyberweapons. DeepSeek’s privacy terms indicate that user data is stored on secure servers located in China, which has led to apprehensions about data sovereignty and user privacy.
In summary, DeepSeek R1 represents a significant advancement in AI development, offering powerful capabilities at a reduced cost and promoting open-source collaboration. As with any technological innovation, it is essential to balance these benefits with careful consideration of potential risks, particularly concerning data privacy and security.
Regarding the code you’ve provided, it appears to be a Power Query M script designed to fetch and process COVID-19 data from the disease.sh API. This script defines a function GetCovidData
to retrieve data from specified endpoints, processes global data, country-specific data, and historical data, and compiles them into a record named FinalData
.
To run this code, you’ll need to use a platform that supports Power Query M language, such as Microsoft Power BI or Excel’s Power Query Editor. Here’s a general guide on how to execute the script in Power BI:
- Open Power BI Desktop: If you haven’t installed it yet, you can download it from the official Power BI website.
- Launch the Query Editor:
- Click on the “Home” tab.
- Select “Transform Data” to open the Power Query Editor.
- Create a New Blank Query:
- In the Power Query Editor, go to the “Home” tab.
- Click on “New Source” and choose “Blank Query”.
- Open the Advanced Editor:
- With the new blank query selected, click on the “Advanced Editor” button in the “Home” tab.
- Paste the Code:
- In the Advanced Editor window, delete any existing code.
- Paste your provided Power Query M script into the editor.
- Apply the Changes:
- Click “Done” to close the Advanced Editor.
- In the Power Query Editor, click “Close & Apply” to execute the script and load the data into Power BI.
After these steps, the data retrieved and processed by your script will be available in Power BI for analysis and visualization.
Please ensure you have an active internet connection, as the script fetches data from an online API. Additionally, be aware that the availability and structure of the API endpoints may change over time, which could affect the script’s functionality.
Here is Code for Covid-19 API:
let GetCovidData = (endpoint as text) => let Source = Json.Document(Web.Contents("https://disease.sh/v3/covid-19/" & endpoint)), Result = if Value.Is(Source, type list) then Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error) else Record.ToTable(Source) in Result, GlobalData = GetCovidData("all"), CountryData = let Source = GetCovidData("countries"), #"Expanded Column1" = Table.ExpandRecordColumn(Source, "Column1", {"country", "cases", "deaths", "recovered", "active", "critical", "countryInfo", "continent"}, {"country", "cases", "deaths", "recovered", "active", "critical", "countryInfo", "continent"}), #"Expanded countryInfo" = Table.ExpandRecordColumn(#"Expanded Column1", "countryInfo", {"lat", "long"}, {"lat", "long"}) in #"Expanded countryInfo", HistoricalData = let Source = Json.Document(Web.Contents("https://disease.sh/v3/covid-19/historical/all?lastdays=all")), Cases = Record.ToTable(Source[cases]), Deaths = Record.ToTable(Source[deaths]), Recovered = Record.ToTable(Source[recovered]), #"Renamed Cases" = Table.RenameColumns(Cases, {{"Name", "RawDate"}, {"Value", "Cases"}}), #"Renamed Deaths" = Table.RenameColumns(Deaths, {{"Name", "RawDate"}, {"Value", "Deaths"}}), #"Renamed Recovered" = Table.RenameColumns(Recovered, {{"Name", "RawDate"}, {"Value", "Recovered"}}), Merged = Table.Join( Table.Join(#"Renamed Cases", "RawDate", #"Renamed Deaths", "RawDate", JoinKind.Inner), "RawDate", #"Renamed Recovered", "RawDate", JoinKind.Inner ), // Custom date parsing #"Split Date" = Table.AddColumn(Merged, "Date", each let parts = Text.Split([RawDate], "/"), month = parts{0}, day = parts{1}, year = "20" & parts{2} in #date(Number.FromText(year), Number.FromText(month), Number.FromText(day)) ), #"Reordered Columns" = Table.ReorderColumns(#"Split Date",{"Date", "RawDate", "Cases", "Deaths", "Recovered"}), #"Removed Columns" = Table.RemoveColumns(#"Reordered Columns",{"RawDate"}) in #"Removed Columns", FinalData = [ Global = GlobalData, Countries = CountryData, Historical = HistoricalData ] in FinalData
Movies Information API:
Steps to Run the Power Query (M) Code:
Open Power BI or Excel Power Query Editor
- If using Power BI, go to Home > Transform Data.
- If using Excel, go to Data > Get & Transform > Get Data > Launch Power Query Editor.
Create a New Query
- Click New Source > Blank Query.
Open the Advanced Editor
- In the Power Query Editor, go to Home > Advanced Editor.
Paste the Code
- Delete any existing code and paste the provided M code.
let // API Configuration API_KEY = "6b694989", BaseUrl = "http://www.omdbapi.com/", // Function to fetch movie data GetMovieData = (searchTerm as text) => let SearchUrl = BaseUrl & "?apikey=" & API_KEY & "&s=" & searchTerm & "&type=movie", Source = Json.Document(Web.Contents(SearchUrl)), Movies = Source[Search], MoviesTable = Table.FromList(Movies, Splitter.SplitByNothing(), null, null, ExtraValues.Error), ExpandedMovies = Table.ExpandRecordColumn(MoviesTable, "Column1", {"Title", "Year", "imdbID", "Type", "Poster"}, {"Title", "Year", "imdbID", "Type", "Poster"}) in ExpandedMovies, // Function to get detailed movie info GetMovieDetails = (imdbID as text) => let DetailUrl = BaseUrl & "?apikey=" & API_KEY & "&i=" & imdbID & "&plot=full", Source = Json.Document(Web.Contents(DetailUrl)), Details = Record.FromList( {Source[Title], Source[Year], Source[Rated], Source[Released], Source[Runtime], Source[Genre], Source[Director], Source[Writer], Source[Actors], Source[Plot], Source[Language], Source[Country], Source[Awards], Source[Poster], Source[Ratings], Source[Metascore], Source[imdbRating], Source[imdbVotes], Source[imdbID], Source[Type], Source[BoxOffice], Source[Production], Source[Website]}, {"Title", "Year", "Rated", "Released", "Runtime", "Genre", "Director", "Writer", "Actors", "Plot", "Language", "Country", "Awards", "Poster", "Ratings", "Metascore", "imdbRating", "imdbVotes", "imdbID", "Type", "BoxOffice", "Production", "Website"}) in Details, // Main query SearchTerm = "action", // Change this to your desired search term InitialSearch = GetMovieData(SearchTerm), AddedDetails = Table.AddColumn(InitialSearch, "Details", each GetMovieDetails([imdbID])), ExpandedDetails = Table.ExpandRecordColumn(AddedDetails, "Details", {"Rated", "Released", "Runtime", "Genre", "Director", "Writer", "Actors", "Plot", "Language", "Country", "Awards", "Ratings", "Metascore", "imdbRating", "imdbVotes", "BoxOffice", "Production", "Website"}, {"Rated", "Released", "Runtime", "Genre", "Director", "Writer", "Actors", "Plot", "Language", "Country", "Awards", "Ratings", "Metascore", "imdbRating", "imdbVotes", "BoxOffice", "Production", "Website"}), // Transformations ChangedTypes = Table.TransformColumnTypes(ExpandedDetails, { {"Year", Int64.Type}, {"Metascore", Int64.Type}, {"imdbRating", type number}, {"imdbVotes", Int64.Type}, {"Released", type date} }), // Expand Ratings RatingsExpanded = Table.ExpandListColumn(ChangedTypes, "Ratings"), RatingsDetails = Table.ExpandRecordColumn(RatingsExpanded, "Ratings", {"Source", "Value"}, {"RatingSource", "RatingValue"}) in RatingsDetails
- Delete any existing code and paste the provided M code.
Modify the Search Term (Optional)
- Change
SearchTerm = "action"
to any desired genre or keyword.
- Change
Run the Query
- Click Done to close the Advanced Editor.
- Click Close & Apply (Power BI) or Close & Load (Excel).
Review the Output
- The query retrieves movie data from the OMDb API, including basic search results and detailed movie information.
- Check the table output for details like Title, Year, IMDb ID, Ratings, Genre, and Director.
Handle API Limitations (If Needed)
- If the API has a request limit, consider running fewer queries or caching results.
World Population API M Query Code:
Steps to Run the Power Query (M) Code:
Open Power BI or Excel Power Query Editor
- If using Power BI, go to Home > Transform Data.
- If using Excel, go to Data > Get & Transform > Get Data > Launch Power Query Editor.
Create a New Query
- Click New Source > Blank Query.
Open the Advanced Editor
- In the Power Query Editor, go to Home > Advanced Editor.
Paste the Code
- Delete any existing code and paste the provided M code.
let // Get data from REST Countries API RestCountries = let Source = Json.Document(Web.Contents("https://restcountries.com/v3.1/all")), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"name", "cca3", "region", "subregion", "population", "area", "latlng"}, {"Name", "ISO3", "Region", "Subregion", "Population", "Area", "Coordinates"}), #"Expanded Name" = Table.ExpandRecordColumn(#"Expanded Column1", "Name", {"common"}, {"Country"}), #"Split Coordinates" = Table.TransformColumns(#"Expanded Name", {"Coordinates", each if _ = null then [Latitude = null, Longitude = null] else [Latitude = _{0}, Longitude = _{1}], type record}), #"Expanded Coordinates" = Table.ExpandRecordColumn(#"Split Coordinates", "Coordinates", {"Latitude", "Longitude"}, {"Latitude", "Longitude"}), #"Changed Type" = Table.TransformColumnTypes(#"Expanded Coordinates",{ {"Country", type text}, {"ISO3", type text}, {"Region", type text}, {"Subregion", type text}, {"Population", Int64.Type}, {"Area", type number}, {"Latitude", type number}, {"Longitude", type number}}) in #"Changed Type", // Rest of the World Bank API and merge steps remain the same... // Get data from World Bank API WorldBank = let Source = Json.Document(Web.Contents("http://api.worldbank.org/v2/country/all/indicator/SP.POP.TOTL?format=json&per_page=300&date=2022")), #"Data List" = Source{1}, #"Converted to Table" = Table.FromList(#"Data List", Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"country", "value", "date"}, {"CountryInfo", "PopulationWB", "Year"}), #"Expanded CountryInfo" = Table.ExpandRecordColumn(#"Expanded Column1", "CountryInfo", {"id", "value"}, {"ISO3", "CountryName"}), #"Filtered Rows" = Table.SelectRows(#"Expanded CountryInfo", each [PopulationWB] <> null and Text.Length([ISO3]) = 3), #"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{ {"ISO3", type text}, {"CountryName", type text}, {"PopulationWB", type number}, {"Year", Int64.Type}}) in #"Changed Type", // Merge datasets MergedData = let Source = Table.NestedJoin(RestCountries, {"ISO3"}, WorldBank, {"ISO3"}, "WorldBank", JoinKind.LeftOuter), #"Expanded WorldBank" = Table.ExpandTableColumn(Source, "WorldBank", {"PopulationWB", "Year"}, {"PopulationWB", "Year"}), #"Merged Population" = Table.AddColumn(#"Expanded WorldBank", "FinalPopulation", each if [PopulationWB] = null then [Population] else [PopulationWB], type number), #"Cleaned Data" = Table.SelectColumns(#"Merged Population", {"Country", "ISO3", "Region", "Subregion", "FinalPopulation", "Area", "Latitude", "Longitude"}), #"Renamed Final Population" = Table.RenameColumns(#"Cleaned Data", {{"FinalPopulation", "Population"}}), #"Filtered Regions" = Table.SelectRows(#"Renamed Final Population", each [Region] <> null), #"Added Density" = Table.AddColumn(#"Filtered Regions", "Density", each [Population] / [Area], type number) in #"Added Density" in MergedData
- Delete any existing code and paste the provided M code.
Modify the Search Term (Optional)
- Change
SearchTerm = "action"
to any desired genre or keyword.
- Change
Run the Query
- Click Done to close the Advanced Editor.
- Click Close & Apply (Power BI) or Close & Load (Excel).
Review the Output
- The query retrieves world poplutation data from the API, including basic search results and detailed movie information.
Handle API Limitations (If Needed)
- If the API has a request limit, consider running fewer queries or caching results.Power BI ProjectsWatch Tutorial
- If the API has a request limit, consider running fewer queries or caching results.Power BI ProjectsWatch Tutorial