Forum Discussion

Justas4478's avatar
Justas4478
Post Prodigy
1 year ago
Solved

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:

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



  • Justas4478's avatar
    Justas4478
    1 year ago

    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"})

10 Replies

  • Hi Justas4478 

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

    CONTAINSSTRING([Store Name], " NI") , "NI", "UK")
    • Justas4478's avatar
      Justas4478
      Post Prodigy

      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.

      • SamWiseOwl's avatar
        SamWiseOwl
        Super User

        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.

         

  • ajohnso2's avatar
    ajohnso2
    Solution Supplier

    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.