Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
dean_rowntree
Regular Visitor

Difference between PowerBI and Powery Query in Excel with same data

Hello

 

I am trying to create a cumulative flow diagram in PowerBi, but my data is not giving me the results I expected. I recreated it in Power Query and got the result I expected.

 

Here is the code for the PowerBI query and resulting table:

let
    Source = tbl_DateWindow,
    #"Added Custom" = Table.AddColumn(Source, "Project name", each List.Distinct(tbl_Cards[Project name])),
    #"Expanded Project name" = Table.ExpandListColumn(#"Added Custom", "Project name"),
    #"Added Custom1" = Table.AddColumn(#"Expanded Project name", "Count", each let
        project = Record.Field(_,"Project name"),
        start = Record.Field(_,"Start date"),
        end = Record.Field(_,"End date"),
        tbl = Table.SelectRows(tbl_Cards, each [Project name]=project and [Created At]>=start and [Created At]<end),
        count = Table.RowCount(tbl)
        in count, type number),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Cumul", each let
        project = Record.Field(_,"Project name"),
        start = Record.Field(_,"Start date"),
        tbl = Table.SelectRows(#"Added Custom1", each [Project name]=project and [Start date]<=start),
        cumul = List.Sum(tbl[Count])
        in cumul, type number),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Count", "End date"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[#"Project name"]), "Project name", "Cumul", List.Sum),
    #"Renamed Columns" = Table.RenameColumns(#"Pivoted Column",{{"Start date", "Date window"}})
in
    #"Renamed Columns"

 

Capture.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

And here is the code from Power Query in Excel and resulting table:

let
    Source = tbl_DateWindow,
    #"Added Custom" = Table.AddColumn(Source, "Project name", each List.Distinct(tbl_Cards[Project name])),
    #"Expanded Project name" = Table.ExpandListColumn(#"Added Custom", "Project name"),
    #"Added Custom1" = Table.AddColumn(#"Expanded Project name", "Count", each let
        project = Record.Field(_,"Project name"),
        start = Record.Field(_,"Start date"),
        end = Record.Field(_,"End date"),
        tbl = Table.SelectRows(tbl_Cards, each [Project name]=project and [Created At]>=start and [Created At]<end),
        count = Table.RowCount(tbl)
        in count, type number),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Cumul", each let
        project = Record.Field(_,"Project name"),
        start = Record.Field(_,"Start date"),
        tbl = Table.SelectRows(#"Added Custom1", each [Project name]=project and [Start date]<=start),
        cumul = List.Sum(tbl[Count])
        in cumul, type number),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom2",{"Start date", "Project name", "Cumul"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Other Columns", List.Distinct(#"Removed Other Columns"[#"Project name"]), "Project name", "Cumul"),
    #"Renamed Columns" = Table.RenameColumns(#"Pivoted Column",{{"Start date", "Date window"}})
in
    #"Renamed Columns"

Capture1.PNG

 

Can anybody see where I am going wrong because this is driving me bananas at the moment!

 

Thank you for reading!

5 REPLIES 5
Anonymous
Not applicable

HI @dean_rowntree,

 

I guest this issue may related to power query lazy evaluation, you can take a look at following links about this:

On lazy value evaluation order in Power Query and Power BI

Power Query M Primer (Part 5): Paradigm

 

Regards,

Xiaoxin Sheng

Thank you for the information, but I don't understand how the same code can produce different reults from the same source data, with the only difference being the application the code is executed in.

Anonymous
Not applicable

HI @dean_rowntree,

 

I also not so sure for the internal calculation logic, maybe you can submit a support ticket to get better support from dev team.

 

Regards,

Xiaoxin Sheng

Thank you for the suggestion, I may try that if I can figure out how to do so.

Did you ever figure this out? I'm having the same issue- I get 2000 lines when I run a query in Excel, but 100 lines when I copy and paste the query into PBI.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.