cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Joachim2108
Helper I
Helper I

Using wildcard characters in a SWITCH function

Hi!

 

I'm struggling to create a new collumn with wildcard characters, based on certain values in another collumn using the SWITCH function.

 

The products in the original collumn are grouped between 100-900 (e.g. 112, 320 etc.). I want to group these into smaller categories.

 

In plain english I want for example: if the ProductGroup starts with 3, i.e. is between 300-399 (data type = text), it needs to be categorised as "Tools". I used wilcard characters in the DAX query, however it doesn't seem to recognise them. A piece of the query is below - what am I doing wrong? Thanks in advance!

 

 

ProductCategory=

SWITCH ( TRUE (),  

 

'Storage’[ProductGroup] = "3**", "Tools",

'Storage’[ProductGroup] = "4**", "Service",

'Storage’[ProductGroup] = "5**", "Transport",

    "Other" )

1 ACCEPTED SOLUTION
Joachim2108
Helper I
Helper I

Hi all, the solution turned out to be:

 

IF (LEFT ( Storage[Productgroup) = LEN(1)) = "3", "Tools",

IF (LEFT ( Storage[Productgroup], LEN(1)) = "4", "Service",

IF (LEFT ( Storage[Productgroup], LEN(1)) = "5", "Transport"

View solution in original post

3 REPLIES 3
Joachim2108
Helper I
Helper I

Hi all, the solution turned out to be:

 

IF (LEFT ( Storage[Productgroup) = LEN(1)) = "3", "Tools",

IF (LEFT ( Storage[Productgroup], LEN(1)) = "4", "Service",

IF (LEFT ( Storage[Productgroup], LEN(1)) = "5", "Transport"

AntrikshSharma
Community Champion
Community Champion

@Joachim2108 Wildcards are not supported in DAX afaik, you will have to use either

 

https://dax.guide/containsstring/

or 

https://dax.guide/containsstringexact/

If I can't use wildcards, could I combine the SWITCH statement with a LEFT statement?

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors