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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Power Query: grouping, summing, and nulls

Let's say I have the following data in a child table:

OrgScore
ABC32
ABC29
ABC33
ABC30
DEF38
DEFnull
DEFnull
DEF36
GHInull
GHInull
GHInull
GHI34

Nulls mean the score hasn't been collected yet.

What I need is to sum up the scores by org, but those orgs that have null scores to return a null, thus indicating that they're not 'finished' yet. When I group and sum in Power Query, it's ignoring the nulls. I can't just filter out the nulls, because then it would look as if all of the orgs are 'finished'.

Is there some way in Power Query to force Sum to return nulls on a grouping? I'm wanting to do this in Power Query to help limit the amount of data sent to the report from the source. The line I have is '= Table.Group(#"Promoted Headers", {"Table1"}, {{"Org", each List.Sum([Score]), type number}})'

I hope this makes sense. TIA

1 ACCEPTED SOLUTION
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

Firstly, add a custom column using the following code in your table.

= if [Score] is null then "error" else [Score]
1.PNG

Secondly, use “Group by” feature to calculate the scores.
2.PNG
  


Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

Firstly, add a custom column using the following code in your table.

= if [Score] is null then "error" else [Score]
1.PNG

Secondly, use “Group by” feature to calculate the scores.
2.PNG
  


Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Community Champion
Community Champion

Something that might help get you there, try sorting your Score column and then using a GroupKind.Local in your Table.Group function. This will return local groups and you will get nulls back from your Table.Group statement. You'll have to do some cleanup but this might get you close enough to what you want to get to a solution.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Anonymous

I'm not sure, if I fully understood your question....

 

Null is treated as zero in your example.

As your data has just 3 entries in org, it sums up the score.

If you change for example one "DEF" null entry to "ttttt" null, it will return this table in the Query Editor aka Power Query:

grafik.png

 

 

 

 

Anonymous
Not applicable

I only want a summed up score if ALL of the scores for an org are not null; otherwise, I want it to return null.

 

I'm thinking of replacing all nulls with a non-numeric value to force an error, though that seems kinda kludgey to me.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.