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

Switch True conditions for values in the same column but different rows

Hello.

 

I am trying to use Switch True that would return a specific value is a particular customer has a certain combination of values (from the same column). However, a customer can have more than one row of data--meaning one value being on one row, and the other value on another row. I want to be able to determine whether or not each customer has the specified Code values from that column (though each Code value is on a different row for the same customer), and then return the appropriate resulting "Code Combination" value.

 

When I try the above approach with my actual data table, the new "Code Combination" column returns blanks. Any assistance is greatly appreciated.

 

For example:

Customer ID     Code        

01737298         WBSA

01737298         WMSA

01568489         WBSM

 

Code Combination =

SWITCH(
     TRUE(),

     'Table'[Code] = "WBSA" && 'Table[Code] = "WMSA", "BS to MS")

3 REPLIES 3
v-diye-msft
Community Support
Community Support

Hi @daviss62 

 

Not sure if you'd like to get below result:

Measure 2 = var a = CALCULATE(MAX('Table (3)'[Customer ID]),FILTER('Table (3)',[Code]="WBSA"))
var b = CALCULATE(MAX('Table (3)'[Customer ID]),FILTER('Table (3)',[Code]="WMSA")) 
Return
IF(a=b,BLANK(),"BS to MS")

16.PNG

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

Hi @v-diye-msft ,

 

That is close to what I want. However, when I plug in my columns/fields into a new calculated column, I get the following "circular dependency" error message.

 

2019-09-17_15h09_42.png

Hi @daviss62 

 

 I am aware of a circular dependency "issue" when you write multiple calc columns, and their incrementally refer to all columns in a table. Did you use calculated com which should be measure instead?

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

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.