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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Danny2020
Regular Visitor

DAX SUM not working with filters

Hello, 

 

I have a large data Table 1 in the following form:

 

ID Product Type Contribution Per Type Measure 1 Measure 2
1 Shoes A 100 20 30
1 Shoes B 20 20 30
1 Shoes C 30 20 30
2 Pants A 40 10 50
2 Pants C 50 10 50

 

I have a slider with filters for fields Type, subtype, from Table 2, showing the options in boxes (multiple selection):

 

Type   Subtype

A         

           AA

           AB

B         

           BA

           BC

C       

           CA

           CB

 

Table 1, and Table 2 are related by the Type field. The desired output table I would like to generate is:

 

Project Name   Total Contribution per type   Value 1      Value 2

Shoes                150                                        20                    30 

 

Pants                 90                                          10                    50

 

Total                 240                                          30                   80

 

The DAX measure I have for Value 1 is = CALCULATE (MAX(Table 1[Value 1]), ALLEXCEPT(Table 2, Table 2[Type], Table2[Subtype]))

 

The result for Value 1 is correct, row by row, and total, if all filters are selected. However, if I select in the filter  Type B in the slider, the values per row are correct, but the total remains = 30. If I select  B, the total for measure 1 should be 20.

 

How can I get a measure for Value 1 that shows the correct total when a filter is selected?

 

Thank you,

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Danny2020 

 

You can use the following two measures:

 
Value 1 Measure = MAX('Table 1'[Value 1])
 
Value 1 Total = SUMX(VALUES('Table 1'[Product]),[Value 1 Measure])
vjingzhang_0-1672221597130.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it. Highly appreciate your Kudos!

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @Danny2020 

 

You can use the following two measures:

 
Value 1 Measure = MAX('Table 1'[Value 1])
 
Value 1 Total = SUMX(VALUES('Table 1'[Product]),[Value 1 Measure])
vjingzhang_0-1672221597130.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it. Highly appreciate your Kudos!

amitchandak
Super User
Super User

@Danny2020 , Try like

 

Sumx(Values(Table2[[Type]) ,CALCULATE (MAX(Table 1[Value 1])))

Hi @amitchandak,

 

Unfortunately the measure is overcounting the total for each project name, and also the general total.

 

Any ideas?

 

Thank you,

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.