cancel
Showing results for
Did you mean:

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a \$100 discount. Register Now

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?

Thanks,

Sam

1 ACCEPTED SOLUTION
Post Prodigy

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

Post Prodigy

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

Announcements

#### Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors
Top Kudoed Authors