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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Xavier
Regular Visitor

Conditionnal Divide of Sums

Hello,

I have a table like this 

 

Period | Site | Client | Revenue | Expense

202204 | France | X | 1000 | 75

202205 | France | X | 1000 | 100

202205 | UK | Y | 500 | 100

202204 | UK | Z | 0 | 50

 

I'd like to create a measure (ratio in %) that I would explain like this in SQL :

Select SUM(Expense)/SUM(Revenue)

Where Revenue > 0

Group By Period, Client, Site

 

The "Group By" describes the fact this measure should automatically be calculated when I select my filter Period and/or Client and/or Site

 

Any Help would be greatful !

Thx

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Xavier 

 

You can try the following methods.

Measure =
CALCULATE (
    DIVIDE ( SUM ( 'Table'[Expense] ), SUM ( 'Table'[Revenue] ) ),
    FILTER (
        ALL ( 'Table' ),
        [Revenue] > 0
            && [Period] = SELECTEDVALUE ( 'Table'[Period] )
            && [Site] = SELECTEDVALUE ( 'Table'[Site] )
            && [Client] = SELECTEDVALUE ( 'Table'[Client] )
    )
)

vzhangti_0-1654248104909.pngvzhangti_1-1654248121028.png

Is this the output you expect?

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @Xavier 

 

You can try the following methods.

Measure =
CALCULATE (
    DIVIDE ( SUM ( 'Table'[Expense] ), SUM ( 'Table'[Revenue] ) ),
    FILTER (
        ALL ( 'Table' ),
        [Revenue] > 0
            && [Period] = SELECTEDVALUE ( 'Table'[Period] )
            && [Site] = SELECTEDVALUE ( 'Table'[Site] )
            && [Client] = SELECTEDVALUE ( 'Table'[Client] )
    )
)

vzhangti_0-1654248104909.pngvzhangti_1-1654248121028.png

Is this the output you expect?

 

Best Regards,

Community Support Team _Charlotte

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

amitchandak
Super User
Super User

@Xavier , Try a measure like

 

calculate( divide(SUM(Table[Expense]),SUM(Table[Revenue])), filter(Table, Table[Revenue] >0 ))

 

Group will be what you take in visual

 

DAX vs SQL: https://www.youtube.com/watch?v=WlvQ_SGy4iA&list=PLPaNVDMhUXGZNyKU0PgG2g3P0c6CPjMnj

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.