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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ashapr
Regular Visitor

Error in DAX function

I have written this DAX function but its not showing correct total.its showing 0 total but toal should be -6407667.

 

Cumulative Balance = IF ( [ShowValueForDates], SWITCH(SELECTEDVALUE(glaccounts[IncomeBalance]), "Balance Sheet", CALCULATE(SUM(glentries[amount]),FILTER(ALL('date'), 'date'[Date] <= MAX('date'[Date]))), "Income Statement", CALCULATE(TOTALYTD(SUM(glentries[Amount]),'date'[Date])),0) )

Please help me to solve this.

 

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ashapr ,

 

I suggest you to try to create a new measure based on [Cumulative Balance] measure instead of sumx it directly.

Cumulative Balance with correct subtotal =
SUMX ( 'glentries', [Cumulative Balance] )

If this reply still couldn't help you solve your problem, please share a sample file with me and show me the result you want. This will make it easier for me to find the solution.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@ashapr ,Try a measure like
Cumulative Balance = sumx(values(glaccounts[IncomeBalance]),calculate(IF ( [ShowValueForDates], SWITCH(SELECTEDVALUE(glaccounts[IncomeBalance])
, "Balance Sheet", CALCULATE(SUM(glentries[amount]),FILTER(ALL('date'), 'date'[Date] <= MAX('date'[Date])))
, "Income Statement", CALCULATE(TOTALYTD(SUM(glentries[Amount]),'date'[Date])),0) )))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

i will try and see.really thanks to you .if you can tell me what is the error in the code that i have written,that would be great.

Anonymous
Not applicable

Hi @ashapr ,

 

I suggest you to try to create a new measure based on [Cumulative Balance] measure instead of sumx it directly.

Cumulative Balance with correct subtotal =
SUMX ( 'glentries', [Cumulative Balance] )

If this reply still couldn't help you solve your problem, please share a sample file with me and show me the result you want. This will make it easier for me to find the solution.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.