Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
connork
Helper I
Helper I

Annual Total not Calculating

I have the following measure to calculate overtime hours as the difference between actual hours worked [Hours] and 'regular' hours [OT Base2]:

 

OT Hoursv2 = 
IF(CALCULATE([Hours],  all(refDatesDAY[Date])) - calculate([OT Base2], all(refDatesDAY[Date]))<0,0,
    CALCULATE([Hours],  all(refDatesDAY[Date])) - calculate([OT Base2], all(refDatesDAY[Date]))
)

 

 

The RefDatesDay table is daily, so the measure is setup to give monthly totals (intended, daily calculations are not accurate).  The totals my month are calculating correctly, but the total for the year is taking the difference of the two figures rather than the sum of the months:


image.png

 

I've tried wrapping in a SUMX, but no luck.


What DAX should I use to get the total above to be the sum of the months (4.5+2.5+6+20=33) rather than 2.5?

Thanks

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @connork,

 

Have you checked this article? Dealing with Measure Totals

 

Besides, if possible, please post some dummy data in source table.

 

Regards,

Yuliana Gu

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

Hi @v-yulgu-msft

Ok - here's the data, the measures and then a videw of the matrix with related columns:

DATA

dataTimedataTime

 

refDatesDAYrefDatesDAY

refEmployeerefEmployee

MEASURES

 

OT Hoursv2 = 
IF(CALCULATE([Hours],  all(refDatesDAY[Date])) - calculate([OT Base2], all(refDatesDAY[Date]))<0,0,
    CALCULATE([Hours],  all(refDatesDAY[Date])) - calculate([OT Base2], all(refDatesDAY[Date]))
)
OT Base2 = calculate(sum(refDatesDAY[OTBaseHours]),
        filter(refDatesDAY,
            refDatesDAY[Date]<=[MeasTerm]
            &&refDatesDAY[Date]>=[MeasHire]))
Hours = sum(dataTime[EMP_HOURS])

 

 

MeasHire = maX(refEmployee[Hire])
MeasTerm = max(refEmployee[Term])

 

 

REPORT VIEW

image.png

image.png

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors