cancel
Showing results for 
Search instead for 
Did you mean: 
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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!