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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Replace or Lookup Values

Hi,


I am relatively new to Power BI. While I am quite comfortable with Excel and SQL, I am finding Power BI a bit of a challenge for some of the things I am wanting to do.

 

This one seems like quite a simple one, but clearly, I am missing something in terms of what do.

I have a table that I am looking to transform/replace some of the values to clean up the data.

 

The original data and what I am looking to produce is below.

 

AccType's with an X1 is an Account Name of ‘Silver Account’, but in the instance of the same Customer (1111 in the example) can have many ‘Silver Account’. So I want to say anything with X1 or anything X1.* (wildcard) is also a ‘Silver Account’.


In PBI, I can certainly create a replace X1 with ‘Silver Account’ and X1.1 with ‘Silver Account’ and so on, but this would take a very long time as there could go up to X1.999 and then there are several other types as well… e.g. X20 or X20.* is ‘Bronze Account’ and M2 or M2.* is ‘Misc Account’.

Is there a way to have a replace that use can use a wildcard or perhaps even a lookup table that has the definitions of the accounts stored in another table and then referred to in PBI?

 

Here is the example data....

 

Here is the Source Data

AccountNoAccTypeCustomerPoints
1111X1X11111256
1111X1.1X1.11111589
1111X1.2X1.2111110002
1111X1.3X1.31111555
1111X1.4X1.41111698
1111X1.5X1.51111148
1111X1.6X1.611112699
1111X1.7X1.7111136985
1111X1.8X1.811111554
1111X1.9X1.911112
1111X1.10X1.10111133
2222X1X1222298
2222X1.1X1.12222933
9999X20X20999978456
9999X20.1X20.19999365
7777M2M277772358
7777M2.1M2.1777723

 

This is what I am looking to have it look like

AccountNoAccTypeAccountNameCustomerPoints
1111X1X1Silver Account1111256
1111X1.1X1.1Silver Account1111589
1111X1.2X1.2Silver Account111110002
1111X1.3X1.3Silver Account1111555
1111X1.4X1.4Silver Account1111698
1111X1.5X1.5Silver Account1111148
1111X1.6X1.6Silver Account11112699
1111X1.7X1.7Silver Account111136985
1111X1.8X1.8Silver Account11111554
1111X1.9X1.9Silver Account11112
1111X1.10X1.10Silver Account111133
2222X1X1Silver Account2222

98

2222X1.1X1.1Silver Account2222933
9999X20X20Bronze Account999978456
9999X20.1X20.1Bronze Account9999365
7777M2M2Misc Account77772358
7777M2.1M2.1Misc Account777723
1 ACCEPTED SOLUTION

Try like this. In Switch move all Exact values first. If true it will not check others

 

Flag = SWITCH(TRUE(),Sheet1[AccType]="X1", "Silver Account"
			,Sheet1[AccType]="S4", "Red Account"
			,SEARCH("X1",Sheet1[AccType],1,0)>0,"Blue Account"
			,SEARCH("X2",Sheet1[AccType],1,0)>0,"Bronze Account"
			,SEARCH("S40",Sheet1[AccType],1,0)>0,"Yellow Account"
				,"Misc Account")

 

 

This means if the first value is true it will not check second. So just order in that manner.

 

Take the updated file from dropbox link again

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

Try

 

Account Name= SWITCH(TRUE(),SEARCH("X1",Sheet1[AccType],1,0)>0,"Silver Account",SEARCH("X2",Sheet1[AccType],1,0)>0,"Bronze Account","Misc Account")

 

pbix:https://www.dropbox.com/s/mpdu188qw33eibv/accountType.pbix?dl=0

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thanks heaps... I have just tried this logic, but I have a scenario where it does not always work.

 

e.g. I have another account type of X12 (and subsequently X12.*) which is another account type.


I almost need a formula than will provide something like...

Any value is exactly "X1" then 'Sivler Account' and "X1.*" then 'Silver Account'
Then would be able to do other Account Types by following the same style of formula.

 

Sorry I should have mentioned that in my original message... I have others such as X4 type accounts that are different to an X40.

 

I have a reference table which I thought might have been an option as a simple lookup and I could just update the reference table instead of the formula if there is ever an extra account type added.

 

The Reference table looks something like this...

 

Acct TypeAccount Name
X1Silver Account
X20Bronze Account
X12Blue Account
M2Misc Account
S4Red Account
S40Yellow Account

 

Try like this. In Switch move all Exact values first. If true it will not check others

 

Flag = SWITCH(TRUE(),Sheet1[AccType]="X1", "Silver Account"
			,Sheet1[AccType]="S4", "Red Account"
			,SEARCH("X1",Sheet1[AccType],1,0)>0,"Blue Account"
			,SEARCH("X2",Sheet1[AccType],1,0)>0,"Bronze Account"
			,SEARCH("S40",Sheet1[AccType],1,0)>0,"Yellow Account"
				,"Misc Account")

 

 

This means if the first value is true it will not check second. So just order in that manner.

 

Take the updated file from dropbox link again

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.