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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
bmk
Helper II
Helper II

Sum based on specific grouping condition

Hello,

 

Based on table below, I wish to create two measures 'total_metric1' and 'total_metric2'. However, the correct total as per my use case for total_metric1 = 500 and total_metric2 = 1700. At the moment, PBI is totaling it as 1000 and 3400 respectively.

 

How can I achieve this optimally via DAX?

 

bmk_0-1657835177593.png

 

1 ACCEPTED SOLUTION
WinterMist
Impactful Individual
Impactful Individual

@bmk 

 

So if you add 01B or 02B to a card visual, they work.

However, if you try to add them to the table visual, you get the following error:

"SummarizeColumns() and AddMissingItems() may not be used in this context."

That's annoying.

 

WinterMist_5-1657851746140.png

The following link provides guidance that we should replace SUMMARIZECOLUMNS with ADDCOLUMNS+SUMMARIZE.

 

https://community.powerbi.com/t5/Desktop/Issue-with-Bar-chart-SummarizeColumns-and-AddMissingItems-m...

 

So I have modified the code here in 01C & 02C.

As a result, these now work correctly within the table visual, as shown.

 

WinterMist_6-1657851915046.png

 

WinterMist_7-1657851958903.png

 

 

WinterMist_8-1657851990517.png

 

Regards,

Nathan

View solution in original post

4 REPLIES 4
WinterMist
Impactful Individual
Impactful Individual

@bmk 

 

No problem.  Glad to help!

WinterMist
Impactful Individual
Impactful Individual

@bmk 

 

So if you add 01B or 02B to a card visual, they work.

However, if you try to add them to the table visual, you get the following error:

"SummarizeColumns() and AddMissingItems() may not be used in this context."

That's annoying.

 

WinterMist_5-1657851746140.png

The following link provides guidance that we should replace SUMMARIZECOLUMNS with ADDCOLUMNS+SUMMARIZE.

 

https://community.powerbi.com/t5/Desktop/Issue-with-Bar-chart-SummarizeColumns-and-AddMissingItems-m...

 

So I have modified the code here in 01C & 02C.

As a result, these now work correctly within the table visual, as shown.

 

WinterMist_6-1657851915046.png

 

WinterMist_7-1657851958903.png

 

 

WinterMist_8-1657851990517.png

 

Regards,

Nathan

Thank you!

WinterMist
Impactful Individual
Impactful Individual

@bmk 

 

WinterMist_0-1657850297025.png

 

WinterMist_1-1657850337056.png

 

WinterMist_2-1657850379619.png

 

WinterMist_3-1657850403713.png

 

WinterMist_4-1657850424632.png

 

Hopefully this is helpful to you.

 

Regards,

Nathan

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.

Top Solution Authors