I’ve been going round in circles with an issue and I’m sure it’s to do with SUMX but I don’t know how to resolve it.
I’m trying to create a report that tracks employee’s flexitime balance by week.
I’ve got one measure where the columns don’t add up to the sum of the individual weeks.
I’ve got the following tables
Time = Employee, date, hours booked, task
Calendar = Date, Week No., Year
Employee = Employee, Working hours per week
I’ve got the following measures that seem to work ok and subtotal ok:
Hours Booked (this is just the sum of hours submitted)
Flex Hours Taken (this is a calculation of Hours booked where the Task = Flexitime)
Hours Booked less Flex (Hours booked - Flex Hours Taken)
Hours per week (Just the number of contracted hours per week)
No of weeks (distinct count of week number)
Contracted hours - (Hours per week * No of weeks)
So my issue is with calculating the flex hours gained in a week:
Flex Hours Gained = if((Hours Booked Less Flex - Contracted Hours)<0,0, Hours Booked less Flex-Contracted hours)
This is the measure that has a mismatch between the individual weeks and the column total.
Having read around I believe this can be resolved with SUMX but I’m not sure of the syntax in this particular case.
Thank you for the incredibly quick reply, and I can confirm it worked a treat.
I want to go away and read up functions used in this measure, what key words would I be best searching for - I kind of understand what when wrong but not sure how to express it?
Just to throw one more resource on the stack that @Melissa recommended, I would also suggest taking a look at the DAX Patterns - Fix Incorrect Totals section compiled by eDNA expert @Greg:
In addition to Greg’s excellent overview, and many of the videos Melissa recommended, it also has links to other related forum posts. This DAX Patterns section is a great resource to check when you run into problems, since Greg has developed patterns for the most common issues/questions we see on the forum, and is regularly adding new ones:
That’s very useful thanks, and thanks for taking the time to help me out.
I just wasn’t sure how to articulate what my problem was so didn’t know where to start to research the solution. I’ve used SUMX before to solve simple issues but didn’t know how to use it in this context.
Looks like I’ve got some light reading to do
Thanks again for taking the time it’s greatly appreciated. I think the money I’ve spent on a subscription to Enterprise DNA is the best money I’ve ever spent in my business , I’ve learnt so much and the response on the forum has been first class.