cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ccarbone
New Member

If statement with wildcards

Hello, 

 

I have about 15 years of data broken out into 4 categorys based on season FA, WI, SP, SU. I am attempting to label each label as Fall, Winter, Spring, Summer.  The data looks like 2020/FA, 2019/FA, 2018/FA...etc for all seasons. 

 

Currently I am doing an endless if by IF(Table = "2020/FA", "Fall", IF (Table = "2020/SP", Spring, IF....

 

This is turning into a very long and repetative processs and I was experimenting with wildcards (*,?) trying to be able to get, 

 

IF(Table = "????/FA", "Fall", IF (Table = "????/SP", Spring, IF...., but neither * or ? was getting picked up as a wildcard. 

 

Should the wildcard characters be outside of the "" or am I having my logic wrong any help is appricated, does not have to be an if statement. 

2 REPLIES 2
colacan
Resolver II
Resolver II

@ccarbone Hi, you can try below CALCUALTE COLUMN;

 

Season =
SWITCH(True,
SEARCH("SP",TABLE[YearSeason],,BLANK())>0,"SPRING",
SEARCH("SU",TABLE[YearSeason],,BLANK())>0,"SUMMER",
SEARCH("FA",TABLE[YearSeason],,BLANK())>0,"FALL",
SEARCH("WI",TABLE[YearSeason],,BLANK())>0,"WINTER", BLANK()
)
 
Thanks
 
Please mark as soluntion if this helped.

 

 

irfanelevated
Helper II
Helper II

Hello,

 

You can try the Containsstring function.

https://docs.microsoft.com/en-us/dax/containsstring-function-dax

 

Thanks,

Irfan

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors