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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.