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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
samnaw
Resolver I
Resolver I

Dividing in DAX Question

Hello:

 

My formula is not calculating the right number:

 

1) As you can see, when I use the formula, for the first row (in red) its gives me the answer as 100%

2) I am supposed to divide the "Red row total" by "Grand total"

3) For example if the row total (red row) is $10,000, its supposed to calculate $10,000/$100,000 = 10%

4) But its not doing that. Its probably doing $10,000/$10,000 = 100%

5) But the 24.16% is correct. It did that calculation correctly. 

 

What am I doing wrong here?

 

samnaw_0-1604002109651.png

 

Thanks, 

Sam

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @samnaw  easy way to debug Dax Calculations is to try smaller chunks of DAX codes and see if the calculations is working fine or not and fix the bit which is wrong.

 

In your case, what i think is you are SUM (Sales) with Filter for year 2021 and instead of using another Filter clause can you try suing && as you are filtering data from same table (Sales) 

 

Something like

SalesMEASURE = 
CALCULATE (
    SUM ( SALES[Sales_CY] ),
    FILTER ( 'SALES',  SALES[Sales_CY]= "2021" && SALES[_flag] ="CARD")
)
/
CALCULATE (
    SUM ( SALES[Sales_CY] ),
    FILTER ( 'SALES',  SALES[Sales_CY]= "2021")
)

 

Hope this helps.

 

Cheers,

-Namish B

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @samnaw  easy way to debug Dax Calculations is to try smaller chunks of DAX codes and see if the calculations is working fine or not and fix the bit which is wrong.

 

In your case, what i think is you are SUM (Sales) with Filter for year 2021 and instead of using another Filter clause can you try suing && as you are filtering data from same table (Sales) 

 

Something like

SalesMEASURE = 
CALCULATE (
    SUM ( SALES[Sales_CY] ),
    FILTER ( 'SALES',  SALES[Sales_CY]= "2021" && SALES[_flag] ="CARD")
)
/
CALCULATE (
    SUM ( SALES[Sales_CY] ),
    FILTER ( 'SALES',  SALES[Sales_CY]= "2021")
)

 

Hope this helps.

 

Cheers,

-Namish B

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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