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

efficient use of DAX sumx


Hi,

I was hoping someone could help me come up with a more efficient way to calculate something.

Basically, an employee can have mutiple leave types on the same day.

If they sum to 10.8 for that employee, I need to change it to 12.

However, there is an additional complication, I only need to do this for particular employee types. This is just denoted by another field in the table.

Here is my formula

New time Measure = sumx(
VALUES('Date'[Date] ),
if( AND('Hours'[Time with balancing Measure] = 10.8,[Employee Type Measure] >=1), 12, 'Hours'[Time with balancing Measure]))

 

To break it down further, 

Here is 

Employee Type Measure = CALCULATE(COUNT('Hours'[Employee]),
FILTER('Hours', 'Hours'[Employee rule] = "SH7DAY12")
)

I use this so I can use it in an If statement above.

 

Time with balancing Measure = sum('Hours'[time with balancing])

and finally, Time with balancing is a calculated column that is an if statement (basically, if one paycode, then add 2 columns together, else make it the existing value.

 

I hope this makes sense

2 REPLIES 2
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

I am not sure what desired result would you want, could you please share your sample data and desired output screenshots for further analysis? You can also upload sample pbix to OneDrive and post the link here. Do mask sensitive data before uploading.

 

Please read this post to get your answer quickly: How to Get Your Question Answered Quickly.

 

Best Regards,

Amy

Anonymous
Not applicable

Thank you for your response @v-xicai 

 

If you look at my data, data unaggregated.jpg

There are 2 examples where there are 2 entries for the same person on the same day.

Now, I would like the data added together per day, and if it is 10.8, change it to 12.

 

But it that needs to occur only if there is a specific "WS rule", which I have converted to a measure so the code would work.

data aggregated.jpg

 

I cannot attach the PBIX file

https://www.dropbox.com/s/q9g7d6ejnuxwips/DAX%20improvement.pbix?dl=0

 

Hopefully that link will work, else, is there a way to send you the file?

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.