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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jenni-Sky
Helper I
Helper I

Filter Based on Sum of Grouped Values

Hi, 

 

I have the following data: 

OrderGBP
53336540126.95
53344412360
53345612173.91
5333879776.29
5334568311.3
5334676482.35
5333996380
5333144997.74
5334562381.74
5333142004.52
5333141720.96

 

I would like to create a Card to Count the number of Distinct Orders which have Sum of GBP > 5000. I would expect value returned to be 7.

And a second Card to Count the number of Distinct Orders which have Sum of GBP > 20000. I would expect value returned to be 2.

 

When I try to apply a filter on GBP, showing "Count Distinct" will give a total of 6 for 5k and 1 for 20k. Showing "Count" gives total of 7 for 5k and 1 for 20k. These are both incorrect - I can see it is looking at the value of the individual lines as opposed to looking at two rows with the same order number:

53345612173.91
5334568311.3

Adding their GBP together, and then applying the filter to the sum of these. 

 

I have tried to create a measure for Sum of GBP in my table. However when I drag and drop this measure into the Filtering tab, it won't let me make any changes to that filter. 

 

Thank you in advance for any help/suggestions! 

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

Either use DAX summarizecolumns or if you have a table with each order number only listed once, then you can use a SUMX. Then put that measure in the card and filter.

 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

 

If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

6 REPLIES 6
V-pazhen-msft
Community Support
Community Support

@Jenni-Sky 

There are many ways can get to the result. I use 2 measures to explain, a combined measure it provided above by someone else.

The logic is the GBP column is not summed by ordernumber, so each row is read separately. All you need is to create a measure that sum the GBP by Order:

 

Sum by Order Measure = CALCULATE(SUM('Order Rec'[GBP]),ALLEXCEPT('Order Rec','Order Rec'[Order]))

 

Then you just create a count measure use the sum by order to filter:

 

DistinctCount Order = CALCULATE(DISTINCTCOUNT('Order Rec'[Order]),FILTER('Order Rec',Sum by Order Measure>5000))

 

 

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

amitchandak
Super User
Super User

@Jenni-Sky , Try like

countx(filter(summarize(Table, table[Order],"_1",sum(table[GBP])),[_1]>5000),[Order])

 

Or use the visual level filter for the sum measure

@amitchandak , I've tried the visual level filter and it doesn't seem to work for me? 

 

Where would I use the countx? I'm not too familiar with DAX and am relatively new to Power BI so am still learning. 

 

Would this work in conjunciton with the existing Page Level Date filter which will also be applied to the cards I am hoping to create? (There is a "Date" column in this table too ) 

 

 

AllisonKennedy
Super User
Super User

Either use DAX summarizecolumns or if you have a table with each order number only listed once, then you can use a SUMX. Then put that measure in the card and filter.

 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 

 

If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@AllisonKennedy , I think this solution will work for me, however I am new to Power BI and am still only learning DAX. 

 

My table is called 'Orders Rec'. 

Column names from this table used on this page of the report are

- Order (which is the column values should be grouped by)

- GBP (which I would want to filter by Sum of GBP for all orders of the same value)

 

I also have a Date Filter on this page of the report, so Orders Rec also has a Date column that needs to be taken into consideration. Would that have an impact on this solution? 

 

@Jenni-Sky 

 

Try this: 

 

Card = COUNTROWS(FILTER(SUMMARIZECOLUMNS('Order Rec'[Order],"SumGBP",SUM('Order Rec'[GBP])),[SumGBP]>5000))
 

Has this post solved your problem? Please mark it as a solution so that others can find it quickly and to let the community know your problem has been solved. 


If you found this post helpful, please give Kudos.

I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 

https://sites.google.com/site/allisonkennedycv


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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