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
admin11
Memorable Member
Memorable Member

How to modify my expression to make it easy add new code for recode ?

Hi All

 
All my below code is working fine , but not easy to maintenance , when i need to add new code for recode. 
 
_Pro Clas D =
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE(
SUBSTITUTE('INVC'[PRO_CLASS_CODE],
"2200","BK BUS TERMINAL"),
"2209","BK ETHERCAT"),
"2207","BK DRIVE"),
"2208","BK EMBEDDED PC"),
"2203","BK FIELD BUS CARD"),
"1234","CL"),
"1234","RW")
 

admin11_0-1619854944541.png

 

Can some one share with me how to simplify the code , so that when i add new pro_class_code , i don't need to add :-

1 ACCEPTED SOLUTION
Sumanth_23
Memorable Member
Memorable Member

hi @admin11 - A better approach would be to maintain the code to desription mapping in a DIMENSION table and perform a lookup and ro derive the description for the code from the DIMENSION table. This was when a new code comes in you need to just add it to the DIMENSION table and all records for the corresponding code will have the new value. 

 

Please vote / mark this response as a solution if this helps you. This will also help other community members who may have a similar question. 

Happy to help!  

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!

Proud to be a Super User!



View solution in original post

4 REPLIES 4
Sumanth_23
Memorable Member
Memorable Member

hi @admin11 - A better approach would be to maintain the code to desription mapping in a DIMENSION table and perform a lookup and ro derive the description for the code from the DIMENSION table. This was when a new code comes in you need to just add it to the DIMENSION table and all records for the corresponding code will have the new value. 

 

Please vote / mark this response as a solution if this helps you. This will also help other community members who may have a similar question. 

Happy to help!  

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!

Proud to be a Super User!



@Sumanth_23 

Yes , that is right approach. Thank you

@admin11 - Happy to help! 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!

Proud to be a Super User!



daxer-almighty
Solution Sage
Solution Sage

It's easy when you do it where it should be done: in Power Query. Data wrangling should never be done in DAX since DAX has a very different purpose in life. DAX = Data Analysis eXpressions. To do data wrangling you should use M---the language that Power Query speaks. If you do that, the maintenance cost will be minimal.

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.