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

SUMX -> month

Hi all!

Hope you all have a nice weekend so far!

 

I'm currently struggling with a SUMX measure.

I want to calculate a cost based on the number of hours spent.

-> in January -> 6 of 150 hours = 4% -> total cost is 6.070 so cost for this item is 243

-> in Februry -> 23 of 164,25 hours = 14% -> total cost is 6.070 so cost for this item is 850

=> total for January and Februari is 1.093 and not 1.120

(1.120 = 12.139 x 9,23%)

 

marcvd_0-1616852518655.png

 

Current measure: RESULT = SUMX(Emp, [TOTAL] * [HOURS %])

 

Thanks a lot!

M

4 REPLIES 4
Anonymous
Not applicable

Hi, 

well, DAX is calculate the SUM too, and here is your problem, not the result column.
So, try to use matrix and not the table and see how you can change the sum, or switch off the sum and use card for your total result. 

Sorry, don't get it.

I'm using a matrix. The 'end result' isn't correct, so using a card do really solve the problem? 😕

marcvd
Frequent Visitor

Thanks for your answer. But this isn't really working for me.

Here is a sample pbix file: https://1drv.ms/u/s!Akj7bUrQd6tMxFD0imuPrUg3lld5?e=lUTWkD

JW_van_Holst
Resolver IV
Resolver IV

Here you are:

SUMX over months.png

 

RESULT = 
VAR __table =
ADDCOLUMNS(
    SUMMARIZE(
        Emp,
        Emp[Month]
    ),
    "@result", CALCULATE(DIVIDE(SUM(Emp[HOURS]), SUM(Emp[HOURS TOTAL])) * SUM(Emp[TOTAL]))
)
RETURN
sumx(__table, [@result])

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.

Top Solution Authors