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
Anonymous
Not applicable

DAX- Incorrect sum of a column based on slicer selection

Hi Community,

Following is a snapshot of my PBI report. I am trying to create a measure based on selection of cost centre. The cost centre selected appears on any of the two columns - 'Primary cost centre' & 'Other cost centres'Capture_emp.PNG

 

Here is the measure :

Total Position Hours =

Var Selectval = values(cost[description])

return

Calculate(sum(Temp[position Hours]),filter(emp, emp[Primary cost centre] in Selectval || emp[Other cost centre] in Seletval))

 

Please note: 'Temp' is a table created from emp table using SUMMARIZE.

Temp = Summarize(emp, position code, position name, emp_code)

 

This measure is giving incorrect result. The expected result in the above example in snapshot is (22.50+38+24+38) =122.50, but the measure results in 146.50. So, its calculating ' position hours' for Assistant account emp codes -002 & 444 twice (24+24), instead of once.

 

Please suggest a solution.Any help is much appreciated.

 

Thanks,

Meena

 

 

 

2 ACCEPTED SOLUTIONS
sturlaws
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

if you provide a sample dataset or sample pbix-file, it is far easier for anyone to help you.

You could try to replace the sum()-part of you expression with something like this:

sumx(SUMMARIZE('Temp';'Temp'[Position code];'Temp'[Position hours]);'Temp'[Position hours])

View solution in original post

Anonymous
Not applicable

Thanks @sturlaws for your response. It would work for someone in similar situation.

Actually, I managed to resolve the issue by modifying a relationship amongst the tables.

 

 

View solution in original post

2 REPLIES 2
sturlaws
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

if you provide a sample dataset or sample pbix-file, it is far easier for anyone to help you.

You could try to replace the sum()-part of you expression with something like this:

sumx(SUMMARIZE('Temp';'Temp'[Position code];'Temp'[Position hours]);'Temp'[Position hours])
Anonymous
Not applicable

Thanks @sturlaws for your response. It would work for someone in similar situation.

Actually, I managed to resolve the issue by modifying a relationship amongst the tables.

 

 

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.