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
akhmad_danial
Helper I
Helper I

SUMX with filter

Hello All,

I'am trying to do something, I thought would be simple but its not working.

I want to know how to get sub total and total: 

 

 Sum of category.jpg

 

 

 

I tried to use sumx and filter, but its not working:

Sub Total =
VAR Permanent = CALCULATE(SUMX(EMPLOYEE,[Count Female]+[Count Male]),EMPLOYEE[EMPL_STATUS#1] = "Permanent")
VAR Contract = CALCULATE(SUMX(EMPLOYEE,[Count Female]+[Count Male]),EMPLOYEE[EMPL_STATUS#1] = "Contract")
Return
CALCULATE(Permanent+Contract)
 
What DAX should i use to calculate this?
Thanks for any help you can give
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @akhmad_danial ,

 

As under "Contract",there is no value,so if you wanna show as you posted,you'd better create a table as below first:

 

Table 2 = SUMMARIZE('Table','Table'[Status],'Table'[Custom])

 

Then create a measure  as below:

 

Measure 2 = IF(ISINSCOPE('Table'[Gender]),COUNT('Table'[Gender]),CALCULATE(COUNT('Table'[Gender]),FILTER(ALL('Table 2'),'Table 2'[Custom]<=MAX('Table 2'[Custom]))))

 

And you will see:

Annotation 2020-06-15 182521.png

For the related .pbix file,pls click here.

 

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi  @akhmad_danial ,

 

As under "Contract",there is no value,so if you wanna show as you posted,you'd better create a table as below first:

 

Table 2 = SUMMARIZE('Table','Table'[Status],'Table'[Custom])

 

Then create a measure  as below:

 

Measure 2 = IF(ISINSCOPE('Table'[Gender]),COUNT('Table'[Gender]),CALCULATE(COUNT('Table'[Gender]),FILTER(ALL('Table 2'),'Table 2'[Custom]<=MAX('Table 2'[Custom]))))

 

And you will see:

Annotation 2020-06-15 182521.png

For the related .pbix file,pls click here.

 

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

Thanks @Anonymous  it worked.

 

Regards,

Akhmad

harshnathani
Community Champion
Community Champion

Hi @akhmad_danial ,

 

Can you please share some sample data and your actual table snapsot?

 

Understand this is a visualzation snapshot which you have posted.

 

Regards,

HN

Hi @harshnathani ,

Thank you for the respons.

 

This is snapsot table,

1.png2.png3.png

 

 

i think when i sort the data employement status, the value has changed.

 

Hope this helps.

 

Thank you.

 

Anonymous
Not applicable

Hi @akhmad_danial

 

Based on my test,in matrix ,you can only achieve the below result.

Annotation 2020-06-15 110239.png

For the field,settings should be as below:

Annotation 2020-06-15 115846.pngAnnotation 2020-06-15 115904.png

For the related .pbix file,pls click here.

 

 
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

Hi @Anonymous ,

Thank you for your response.

 

I already to set row sub total before but the result not as expected.

I want to calculate (like this, click here) :

 

Subtotal =  Permanent (Male + Female) + Dir (Male + Female) + Expat (Male + Female)

Total = Subtotal + Contract (Male + Female) 

 

This is pbix file

 

Regards,

Akhmad

 

 

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.