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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

sumx by week not giving right answer

hello everyone ,
i have a calculation 

measure =
VAR value = sum([total])
RETURN
sumx(values(week nb),if ( [gross profit] > 0 , value , 0))

and i have a week slicer .

if i slect week 1, value was 10 but we were on a loss, so gross profit was negative so result of value gives 0 
if i select week 2, value was 20 ,we were on profit, so gross profit was positive so result gives value 20

now if i select week 1 and week 2 together i am not getting getting 20 , iam getting 30. how can i solve this?



2 ACCEPTED SOLUTIONS
FreemanZ
Super User
Super User

@Anonymous Assumimg [Total] is a column, try this
measure =
SUMX(
    VALUES(week nb),
     IF (
         [gross profit]>0, 
         CALCULATE(SUM([Total]), 
         0
     )
)

View solution in original post

Anonymous
Not applicable

No error just didnt add up correct but i found a turn around and was able to fix my issue by adding the if to another measure formula that directly affect my formula similar to your suggestion,thank you for your time and help

View solution in original post

5 REPLIES 5
FreemanZ
Super User
Super User

@Anonymous Assumimg [Total] is a column, try this
measure =
SUMX(
    VALUES(week nb),
     IF (
         [gross profit]>0, 
         CALCULATE(SUM([Total]), 
         0
     )
)
Anonymous
Not applicable

Hello @FreemanZ thank you for your response unfortunately doesnt work

what error do you get? And if would be good if you could also share the header of your data table, so to avoid spelling issues.  

Anonymous
Not applicable

No error just didnt add up correct but i found a turn around and was able to fix my issue by adding the if to another measure formula that directly affect my formula similar to your suggestion,thank you for your time and help

Glad to hear that.  Solving the problem by oneself with only some hint from others would be the best outcome. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.