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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
Anonymous
Not applicable

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

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

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

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.

Top Solution Authors
Top Kudoed Authors