Power Query Slow Update

dgantony

New Member
Joined
Mar 22, 2020
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi All
I'm a PQ newbie and have been learning to do my tasks with the help of the internet. Thank you for countless times you all have helped.

For this particular project, I've basically solved the problems using the answers I found on the internet. The issue is that it's taking too long to update. Here's what I'm trying to do.
  1. Grab data from the European CDC that has the daily update of COVID-19 cases and deaths by country
  2. Put it in a table and use PQ to transform the data to get the following:
    1. Calculate the running total of the daily cases so I can view the cumulative cases
    2. Calculate the first day of case in each country so I can time-align the curves
The PQ works the way I want but takes almost 10 mins to update. I would greatly appreciate any help in making this code work faster.

Is there a way to upload the file? I don't see the option on here.

Here's the mcode:

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="COVID19Data"]}[Content],
    ChangeType = Table.TransformColumnTypes(Source,{{"DateRep", type date}, {"Day", Int64.Type}, {"Month", Int64.Type}, {"Year", Int64.Type}, {"Cases", Int64.Type}, {"Deaths", Int64.Type}, {"Countries and territories", type text}, {"GeoId", type text}}),
    RemoveExtraColumns = Table.RemoveColumns(ChangeType,{"Day", "Month", "Year"}),
    RenameCountryColumn = Table.RenameColumns(RemoveExtraColumns,{{"Countries and territories", "Geography"}}),
    SortRows = Table.Sort(RenameCountryColumn,{{"Geography", Order.Ascending}, {"DateRep", Order.Ascending}}),
    AddIndex = Table.AddIndexColumn(SortRows, "Row", 1, 1),
    AddRunningTotal = Table.AddColumn(AddIndex, "Running Total", each let Group=[Geography], Row=[Row] in List.Sum(Table.SelectRows(AddIndex, each [Row]<=Row and [Geography]=Group)[Cases])),
    RemoveZero = Table.SelectRows(AddRunningTotal, each ([Running Total] <> 0)),
    GroupGeographies = Table.Group(RemoveZero, {"Geography"}, {{"GeoGroup", each _, type table [DateRep=date, Cases=number, Deaths=number, Geography=text, GeoId=text, Row=number, Running Total=number]}}),
    AddGeoIndex = Table.AddColumn(GroupGeographies, "GeoIndex", each Table.AddIndexColumn([GeoGroup],"Day Number",1,1)),
    RemovedGeoGroup = Table.RemoveColumns(AddGeoIndex,{"GeoGroup"}),
    #"Expanded GeoIndex" = Table.ExpandTableColumn(RemovedGeoGroup, "GeoIndex", {"DateRep", "Cases", "Deaths", "Running Total", "Day Number"}, {"DateRep", "Cases", "Deaths", "Running Total", "Day Number"})
in
    #"Expanded GeoIndex"

Thanks and stay safe...
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Thank you mole999 for the quick response. Sorry, I should have been clear in my original post. The data download itself is manual and I copy paste the data into an excel table. The issue is really the sub-optimal mcode I've stitched together from multiple sources. :)
 
Upvote 0
Thank you mole999 for the quick response. Sorry, I should have been clear in my original post. The data download itself is manual and I copy paste the data into an excel table. The issue is really the sub-optimal mcode I've stitched together from multiple sources. :)
Then its likely to be machine spec, and formulas i'm guessing, there are a few here that get PQ, I've got lots to learn and no time, the links might help you visualise what is currently reported and stitched together
 
Upvote 0
Those links are really cool, just checked them out. I didn't realize that they were related to my question initially. Thought that they were part of your footer. ?‍♂️
Thanks for those.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top