cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Lorrec
New Member

Power BI Column Query with Multiple Conditions

I have a Power BI dashboard that I built several years ago. I have a column in the dashboard that looks at the sixth letter in the server name. Based on it. The columns determine the environment. For example, for a server with the name serverx123, the environment would be Env1. 

 

I got a recent request to update the dashboard to show Room1 for servers with specific names. For example, serverx123 should now display in the dashboard as Room1 for their environment, not Env1. However, any server not explicitly listed should follow the switch flow. For example, serverx123 would be Room1, but serverx245 would be Env1.

 

I have tried multiple edits to my column DAX query but keep hitting roadblocks. Can someone point me in the right direction? Thank you for the help.

 

My Column

Column = SWITCH(REPLACE(LEFT(TRIM('Append'[Server Name]), 6), 1, 5, ""), "X", "Env1", "L", "Env2","No Env")

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

Hi  @Lorrec ,

 

I think you could nest another if statement, like this:

Column =
IF (
    'Append'[Server Name] = "serverx123",
    "Room1",
    SWITCH (
        REPLACE ( LEFT ( TRIM ( 'Append'[Server Name] ), 6 ), 1, 5, "" ),
        "X", "Env1",
        "L", "Env2",
        "No Env"
    )
)

 

Best Regards,
Gallen Luo
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

2 REPLIES 2
v-jialluo-msft
Community Support
Community Support

Hi  @Lorrec ,

 

I think you could nest another if statement, like this:

Column =
IF (
    'Append'[Server Name] = "serverx123",
    "Room1",
    SWITCH (
        REPLACE ( LEFT ( TRIM ( 'Append'[Server Name] ), 6 ), 1, 5, "" ),
        "X", "Env1",
        "L", "Env2",
        "No Env"
    )
)

 

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

Thank you for the help. I tried something similar but could not get it to work. Your example was what I needed.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors