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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dkalina97
Helper I
Helper I

DAX - change denominator based on a filtered column value

Currently I am displaying a ratio that shows the expense $ by department divided by the total revenue.

(MTD Exp to Revenue % =

Divide([MTD Expense],('Actual Revenue'[Actual MTD Gross Revenue for Ratio])).
 
The numerator is defined by the department based on the chart of accounts, and the denomintor is the same for all departments in the column. MTD Expense is simply 
 
MTD Expense =
CALCULATE(Sum(AccountTransactions[Monthly Expense]),DATESMTD('Dates'[Date]))
 
What I would like to do is change the denominator so that, if Department = Assembly, the the Denominator would be Equipment Sales, Rather than Total Sales. 
 
dkalina97_0-1632426870960.png

 

2 ACCEPTED SOLUTIONS

A SWITCH should do the trick.

 

MTD Exp to Revenue % =
VAR Denom =
    SWITCH (
        SELECTEDVALUE ( Department[Department] ),
        "Assembly", [Equipment Sales],
        "Other Department", [Different Sales Figure],
        [Total Sales]
    )
RETURN
    DIVIDE ( [MTD Expense], Denom )

 

 

View solution in original post

You'll need to sum over the granularity you are showing in your visual (or a finer granularity).

SUMX ( VALUES ( Department[Department] ), [$ Variance to Budget B/(W)] )

 

View solution in original post

5 REPLIES 5
dkalina97
Helper I
Helper I

How would I set up a second Variable? One other department would use a different sales figure, the remainder would be total sales.

A SWITCH should do the trick.

 

MTD Exp to Revenue % =
VAR Denom =
    SWITCH (
        SELECTEDVALUE ( Department[Department] ),
        "Assembly", [Equipment Sales],
        "Other Department", [Different Sales Figure],
        [Total Sales]
    )
RETURN
    DIVIDE ( [MTD Expense], Denom )

 

 

This worked, thank you so much! My last question. Because of the weighting, how do I sum the measure? Example, $ Variance to Budget should be -21,033. It is doing the math of the percent minues the percent, times the grand total sales, just as the rows above, rather than summing the rows above. Thank you!

dkalina97_0-1632495650638.png

 

You'll need to sum over the granularity you are showing in your visual (or a finer granularity).

SUMX ( VALUES ( Department[Department] ), [$ Variance to Budget B/(W)] )

 

AlexisOlson
Super User
Super User

You can set up the logic like this:

 

MTD Exp to Revenue % =
VAR Denom =
    IF (
        SELECTEDVALUE ( Department[Department] ) = "Assembly",
        [Equipment Sales],
        [Total Sales]
    )
RETURN
    DIVIDE ( [MTD Expense], Denom )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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