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
Lidou_Cand
Helper III
Helper III

Calculate Ratio Issue

Hello,
I'm newbie in dax.
I need your help to calculate a ratio.
I have a matrix like this: IssueMatrix.png
I need to calculate a ratio like this: Sales Customer / Sales Category

Can you help me ?

Is thera a way to add a pbix file to this discussion ?

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @Lidou_Cand 

 

You may try the following measure to see if it helps. The pbix file is attached in the end.

Result = 
IF(
    NOT(ISBLANK([Sales Amount])),
    DIVIDE(
        [Sales Amount],
        CALCULATE(
            [Sales Amount],
            FILTER(
                ALL(Sales),
                RELATED('Product'[Category])=SELECTEDVALUE('Product'[Category])&&
                RELATED('Date'[Year]) in DISTINCT('Date'[Year])
            )
        )
    )
)

 

Result:

b1.png

 

Best Regards

Allan

 

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

7 REPLIES 7
v-alq-msft
Community Support
Community Support

Hi, @Lidou_Cand 

 

You may try the following measure to see if it helps. The pbix file is attached in the end.

Result = 
IF(
    NOT(ISBLANK([Sales Amount])),
    DIVIDE(
        [Sales Amount],
        CALCULATE(
            [Sales Amount],
            FILTER(
                ALL(Sales),
                RELATED('Product'[Category])=SELECTEDVALUE('Product'[Category])&&
                RELATED('Date'[Year]) in DISTINCT('Date'[Year])
            )
        )
    )
)

 

Result:

b1.png

 

Best Regards

Allan

 

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

ryan_mayu
Super User
Super User

@Lidou_Cand 

please try to create a measure

=SUM(AMOUNT)/CALCULATE(SUM(AMOUNT),ALLEXCEPT(TABLE,CATEGORY))

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hello,

 

Thank you for your help.

It doesn't work because the denominator is still filtered by the row.

Is there a way to remove all the filters for rows for the denominator ?

Cause It may be confusing, I share a light pbix to explain what I need.

 

Thks a lot

amitchandak
Super User
Super User

@Lidou_Cand ,  The information you have provided is not making the problem clear to me. Can you please explain with an example.

In case you are looking for % of subtotal

https://community.powerbi.com/t5/Desktop/Percentage-of-subtotal/td-p/95390

Percent of Tota;

https://community.powerbi.com/t5/Desktop/Create-measure-of-total/td-p/7808

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. You can load on onedrive or dropbox and share a link
Appreciate your Kudos.


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

PBIX Ratio Issue 

 

Hello,

This a pbix I used for my test.

Thanks for your help.

 

@Lidou_Cand , Checked file

Try This

% = divide([Sales Amount], CALCULATE( [Sales Amount], ALLSELECTED(Sales)))

 

or

% = divide([Sales Amount], CALCULATE( [Sales Amount], ALL(Sales)))

 

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

Hello,

 

When I use ALL or ALLSELECTED for the whole Table (Sales), I have cross join with row with no data.

Is there a way to calculate the measure for only rows with data ?

In SQL it will be: CASE WHEN [Measure] is not null then Calculate......

Is a way to do it in DAX ??

 

 

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.