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
swilcox
Frequent Visitor

VALUES function - adding extra condition

Hi There,

I'm very new to Power BI and DAX.  I currently have this DAX

 

GrossWithCosts (Station Net) = SUMX(
VALUES('Data'[StationShortName])
,
var thisProduct = 'Data'[StationShortName]
var thisFactor = IF(thisProduct = "Station1" , 0.33 , 1 )
return
CALCULATE(SUM('Data'[GrossWithCosts]) * thisFactor
)
)
 
which correctly returns a NET value of 33% of the revenue IF Station1 has revenue.
How do I add an additinal Station into this DAX with a different %.
eg: IF Station2 then multiple by 0.2
 
End result being 1 NET column with different stations filtered by different %'s.
thanks
Shannon
1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@swilcox 

 

Try with following

 

GrossWithCosts (Station Net) =
SUMX (
    VALUES ( 'Data'[StationShortName] ),
    VAR thisProduct = 'Data'[StationShortName]
    VAR thisFactor =
        SWITCH (
            TRUE (),
            thisProduct = "Station1", 0.33,
            thisProduct = "Station2", 0.2,
            1
        )
    RETURN
        CALCULATE ( SUM ( 'Data'[GrossWithCosts] ) * thisFactor )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@swilcox 

 

Try with following

 

GrossWithCosts (Station Net) =
SUMX (
    VALUES ( 'Data'[StationShortName] ),
    VAR thisProduct = 'Data'[StationShortName]
    VAR thisFactor =
        SWITCH (
            TRUE (),
            thisProduct = "Station1", 0.33,
            thisProduct = "Station2", 0.2,
            1
        )
    RETURN
        CALCULATE ( SUM ( 'Data'[GrossWithCosts] ) * thisFactor )
)

Regards
Zubair

Please try my custom visuals

I have a further factor to add to this DAX.

Station1 remains as below.

I also need to include IF Year = 2019 or greater then Station 2 is multiplied by 0.2

AND if year = 2018 then Station2 is multiplied by 0.18

AND if year is 2017 or less then Station2 is multipled by 0.4

 

my year field is in a seperate Calendar table

 

is this possible?

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.