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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Issue in applying SWITCH case with IF condition

Hi Team,

 

Kindly help me applying this DAX query - SWITCH Case

 

Measure1 =
SWITCH(
FILTER('Raw Data', 'Raw Data'[Market Tier - Budget location]= "T40 (Incl US)"),
var aa= CALCULATE(SUM('Raw Data'[Budget]),FILTER('Raw Data','Raw Data'[Year]=2020))/1000000
return aa+ CALCULATE(SUM(Categories_US_Final[TOTAL]),FILTER(Categories_US_Final,Categories_US_Final[Categories]="TOTALS"),FILTER(Categories_US_Final,Categories_US_Final[Year]="2020")),
CALCULATE(SUM('Raw Data'[Budget]),FILTER('Raw Data','Raw Data'[Year]=2020))/1000000
)
 
Showing error saying expressions refers to multiple columns.
 
Basically I want to filter out data:
When Market Tier Budget location = T40 (Incl US) then
            1. Need to sum Budget from Raw data and filter of year 2020 
Add
           2. TOTALS from Categories_US_FINAL[TOTAL] and filter of year 2020
 
Else only Need to sum Budget from Raw data and filter of year 2020 
 
Kindly suggest.
 
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Your first argument in your SWITCH is a table. It needs to be a single scalar value.

 

I'd suggest reworking your measure like this:

Measure1 =
VAR Budget =
    CALCULATE (
        SUM ( 'Raw Data'[Budget] ),
        KEEPFILTERS ( 'Raw Data'[Year] = 2020 )
    ) / 1000000
RETURN
    SWITCH (
        SELECTEDVALUE ( 'Raw Data'[Market Tier - Budget location] ),
        "T40 (Incl US)",
            CALCULATE (
                SUM ( Categories_US_Final[TOTAL] ),
                KEEPFILTERS ( Categories_US_Final[Categories] = "TOTALS" ),
                KEEPFILTERS ( Categories_US_Final[Year] = "2020" )
            ) + Budget,
        Budget
    )

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

Your first argument in your SWITCH is a table. It needs to be a single scalar value.

 

I'd suggest reworking your measure like this:

Measure1 =
VAR Budget =
    CALCULATE (
        SUM ( 'Raw Data'[Budget] ),
        KEEPFILTERS ( 'Raw Data'[Year] = 2020 )
    ) / 1000000
RETURN
    SWITCH (
        SELECTEDVALUE ( 'Raw Data'[Market Tier - Budget location] ),
        "T40 (Incl US)",
            CALCULATE (
                SUM ( Categories_US_Final[TOTAL] ),
                KEEPFILTERS ( Categories_US_Final[Categories] = "TOTALS" ),
                KEEPFILTERS ( Categories_US_Final[Year] = "2020" )
            ) + Budget,
        Budget
    )
Anonymous
Not applicable

Thank a lot for quick response. It's helpful.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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