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
Justas4478
Post Prodigy
Post Prodigy

Customer group split based on stores

Hi, I have customer group that holds stores for UK & NI in the same group.

I want to split it in to two groups Stores NI and whats left Stores UK.
The problem is NI stores get added and removed every time so I cant choose stores manualy and I need some way to define NI stores in order to create new group.
Here is example of some stores:

Justas4478_0-1731925993148.png

As you see majority of stores have 'NI' in their name that could be something that can be used as filter to group them.
Unfortunately to that there is one store that does not have NI in it (could be chance that it will be moved soon), and other two have 'NI' in the middle of the name.
Let me know if anyone has any ideas how to solve it.
If there is solution using M code.
Thanks



1 ACCEPTED SOLUTION

@SamWiseOwl I think I manage to find solution in M code:
Table.ReplaceValue(#"Renamed Columns1",each [Customer Group Description],each if Text.Contains([Store Name], " NI") or [Store Number] ="1378" then "Stores NI" else [Customer Group Description],Replacer.ReplaceText,{"Customer Group Description"})

View solution in original post

10 REPLIES 10
ajohnso2
Super User
Super User

If i were you I would be looking to have a stores Dimension table where you can assign the correct NI/UK flag before loading into your model and then join this to your fact table on store number. If this is not possible @SamWiseOwl suggestion is probably the way to go however you will have to account for future variations of your search string.

SamWiseOwl
Super User
Super User

Hi @Justas4478 

You could creater a Calculated Column in the Table view:
Location =
If( 

CONTAINSSTRING([Store Name], " NI") , "NI", "UK")

If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

@SamWiseOwl Is this going to as well check other versions of NI for example:
'Ni', 'ni' or if they appear inside store names like this, 'Keniworth'?
Since these are my concerns if they will get considered as part of 'NI' group.

It isn't case sensitive.

Note I put " NI" the space infront means it can't be in Keniworth as it won't have a space in front of it.

 


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

@SamWiseOwl I think it could work but I am not sure how it integrates with other groupings.
Here is full list of groupings:

Justas4478_0-1731927914266.png

Beause of that it might have to be M code solution.

Hi @Justas4478 

Could you not add this new column into the slicer.

They can then expand the Stores UK & NI and tick which they wanted.


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

@SamWiseOwl If I understand correctly is it not going to group all the aother stores under UK group from other customer groups?

You could inclue them in the test.

New Column =

Switch(
True()
,[Customer Group Description] <> "Stores UK & NI" --if not this

,[Customer Group Description] --return original value

,ContainsString([Store Name], " NI")

,"Stores NI"

,"Stores UK"
)


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

@SamWiseOwl I think I manage to find solution in M code:
Table.ReplaceValue(#"Renamed Columns1",each [Customer Group Description],each if Text.Contains([Store Name], " NI") or [Store Number] ="1378" then "Stores NI" else [Customer Group Description],Replacer.ReplaceText,{"Customer Group Description"})

Anonymous
Not applicable

Hi @Justas4478 , hello all, thank you for your prompr reply!

I'm glad to hear you found a solution and thank you for sharing it.

 

Please remember to accept your solution as answer.

 

It will do great help to those who meet the similar question in this forum.

 

Thanks again for your contribution.

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.