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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
admin11
Memorable Member
Memorable Member

How to force G16 recode to AO ?

Hi All

I have below workig fine expression from @pranit828  which recode the field GROUP_TYPE into only those value label i want to see :-

 

GROUP_TYPE_C = IF ( ISBLANK('Group TYPE'[GROUP_TYPE]), "No",if('Group TYPE'[GROUP_TYPE] in {"G1","G2","G3","G4","G5","G16"},'Group TYPE'[GROUP_TYPE], "Other"))
 
I have below expression from @v-yangliu-msft
 which help to recode G1 to GT , G2 to AP  .... etc  
 
GROUP_TYPE_CO =
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE('Group TYPE'[GROUP_TYPE_C],
"G1","GT"),
"G2","AP"),
"G3","SL"),
"G4","CL"),
"G5","RW"),
"G16","AO")
 
My issue is for G16 it should recode as AO , but it does not work fine , not sure where it the problem :-
 
admin11_0-1617529620909.png

 

 My PBI file :-
 
Paul
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@admin11 , Try like this as we are using a function that works on  *value*, it means G16 should come before G1

 

GROUP_TYPE_CO = 
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE('Group TYPE'[GROUP_TYPE_C],
"G16","AO"),
"G2","AP"),
"G3","SL"),
"G4","CL"),
"G5","RW"),
"G1","GT")

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@admin11 , Try like this as we are using a function that works on  *value*, it means G16 should come before G1

 

GROUP_TYPE_CO = 
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE('Group TYPE'[GROUP_TYPE_C],
"G16","AO"),
"G2","AP"),
"G3","SL"),
"G4","CL"),
"G5","RW"),
"G1","GT")

@amitchandak 

no wonder you are supper user

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.