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
Nomi5007
Frequent Visitor

I have Create calculated Measure TOPN using sumx it does not bringing correct result.

Hello guys
I need a little help regarding calculated measure. I have created calculated measure suing DAX SUMX function. 

I need to calculate top 10 employee by expense as a single measure. please see attached screen shot and help me whats wronge with my DAX expression. I am not getting any error either.problem1.PNG

 

1 ACCEPTED SOLUTION

Hi @Nomi5007,

Based on my test, you could refer to below formula:

Measure2 = var temptable=TOPN(10,ALLSELECTED(Sheet1),CALCULATE(SUM('Report 1'[$ Amount]),USERELATIONSHIP(Sheet1[Worker ID],'Report 1'[worker ID])))
return
SUMX(temptable,CALCULATE(SUM('Report 1'[$ Amount]),USERELATIONSHIP(Sheet1[Worker ID],'Report 1'[worker ID])))

Result:

1.PNG

You could also download the pbix file to have a view.

 

Regards,

Daniel He

 

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

View solution in original post

4 REPLIES 4
v-danhe-msft
Employee
Employee

Hi @Nomi5007,

Could you have checked if there is other filter for your data? Could you have tried use ALL() function in your formula? If it stlii could not work for you, could you please offer your sample data to have a test if possible?

 

Regards,

Daniel He

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

Yes I have changed the expression like this

Top 10 employee by Expenses = SUMX(TOPN(10, ALL('Report 1'),'Report 1'[Legal Name]),[Total Amount])
got the same result. 
legal name and total amount comming from two different table joined on unique ID. 
I have added two files on google drive please download it from here

Hi @Nomi5007,

Based on my test, you could refer to below formula:

Measure2 = var temptable=TOPN(10,ALLSELECTED(Sheet1),CALCULATE(SUM('Report 1'[$ Amount]),USERELATIONSHIP(Sheet1[Worker ID],'Report 1'[worker ID])))
return
SUMX(temptable,CALCULATE(SUM('Report 1'[$ Amount]),USERELATIONSHIP(Sheet1[Worker ID],'Report 1'[worker ID])))

Result:

1.PNG

You could also download the pbix file to have a view.

 

Regards,

Daniel He

 

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

Thank you it works 

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.