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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

How to write if else in power Bi Dax

Hello All,

 

I have a tableau dashboard where I have parameter having values like US-Canada,APAC and Overall.

And I have department values like Central,Georgia,Hyd and Pune

 

My requirement is If I select region as US-Canada then I need to show only Central,Georgia

                               If I select region as APAC then I need to show only Hyd,Pune

                                If I select region as Overall then I need to show All 4.i.e, Central,Georgia,Hyd,Pune

 

Below is my logic in Tableau and I am not sure how to write in power BI as I am new.

Could some one help how to write

 

I created a table inside power BI for the parameter values and not sure how to write after that

 

CASE [Region]
when 'US-Canada' then
[Department] = 'Central' or
[Department]= 'Georgia'
when 'APAC' then
[Department] = 'Hyd' or
[Department]= 'Pune'

when 'Overall' then
[Department] = 'Central' or
[Department] = 'Georgia' or
[Department]= 'Hyd' or
[Department] = 'Pune'
END

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

Hi @Anonymous ,

 

Please try to Create a new table for slicer:

For Slicer =
FILTER (
    CROSSJOIN (
        { "US-Canada", "APAC", "Overall" },
        SUMMARIZE ( 'Table', [Department] )
    ),
    SWITCH (
        [Value],
        "APAC",
            [Department] = "Hyd"
                || [Department] = "Pune",
        "US-Canada",
            [Department] = "Central"
                || [Department] = "Georgia",
        [Department] = "Hyd"
            || [Department] = "Pune"
            || [Department] = "Central"
            || [Department] = "Georgia"
    )
)

vjianbolimsft_1-1661840970318.png

 

Then manage the relationship between the tables:

vjianbolimsft_0-1661840948556.png

Then apply 'For Slicer'[Value] and 'For Slicer'[Department] to slicers

Final output:

vjianbolimsft_3-1661841218865.png

 

vjianbolimsft_2-1661841181303.png

 

Best Regards,

Jianbo Li

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

4 REPLIES 4
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please try to Create a new table for slicer:

For Slicer =
FILTER (
    CROSSJOIN (
        { "US-Canada", "APAC", "Overall" },
        SUMMARIZE ( 'Table', [Department] )
    ),
    SWITCH (
        [Value],
        "APAC",
            [Department] = "Hyd"
                || [Department] = "Pune",
        "US-Canada",
            [Department] = "Central"
                || [Department] = "Georgia",
        [Department] = "Hyd"
            || [Department] = "Pune"
            || [Department] = "Central"
            || [Department] = "Georgia"
    )
)

vjianbolimsft_1-1661840970318.png

 

Then manage the relationship between the tables:

vjianbolimsft_0-1661840948556.png

Then apply 'For Slicer'[Value] and 'For Slicer'[Department] to slicers

Final output:

vjianbolimsft_3-1661841218865.png

 

vjianbolimsft_2-1661841181303.png

 

Best Regards,

Jianbo Li

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

 

v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I have created a simple sample:

vjianbolimsft_0-1661837582172.png

Please try:

First create a new table for slicer

vjianbolimsft_1-1661837687861.png

Then apply it to slicer and turn on single select :

vjianbolimsft_2-1661837735869.png

vjianbolimsft_3-1661837777987.png

Create a measure and apply to the visual:

Flag = 
SWITCH (
    SELECTEDVALUE ( 'For Slicer'[Value] ),
    "APAC",
        IF (
            MAX ( 'Table'[Department] ) = "Hyd"
                || MAX ( 'Table'[Department] ) = "Pune",
            1,
            0
        ),
    "US-Canada",
        IF (
            MAX ( 'Table'[Department] ) = "Central"
                || MAX ( 'Table'[Department] ) = "Georgia",
            1,
            0
        ),
    1
)

Apply it to the filter:

vjianbolimsft_4-1661838537387.png

Final output:

vjianbolimsft_5-1661838607213.png

vjianbolimsft_6-1661838623068.png

Refer to : IF function (DAX) - DAX | Microsoft Docs

Best Regards,

Jianbo Li

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

 

 

 

 

 

 

 

 

Anonymous
Not applicable

Hi @v-jianboli-msft ,

 

Thanks for your answer.We are almost done

But my requirement here is I need to show the departments as filters to the report.(Need to show them in a slicer )

 

lbendlin
Super User
Super User

You would create groups in Power BI for this, no need for DAX

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.