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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Extracting and comparing ranges

Hello, I've spent a ton of hours trying to find an answer to this problem, but there doesn't seem to be any as far as I can tell.

 

My goal is to create a column that identifies if the date is a working day. The issue is that I can't seem to extract the date for the day after Thanksgiving for each year. Here's what I have:

 

I have a date table spanning from 2020-2029.

I have a holiday table that contains a column for the dates of major US holidays and a column labeling those holidays.

 

I was able to get the holidays over to the date table with the lookupvalue function, but I also need to identify the day after thanksgiving. I know I could just manually look up the dates and insert them, but I wanted to see if there was a more automated method to doing this.

 

On a related note, is there a way of comparing a column from the date table to a range of values from a column in the holiday table. Not all of the major holidays are counted as "company holidays" so I really wanted to do something along the lines of:

 

WorkingDay = IF('DateTable'[Holiday] = ("Memorial Day", "Thanksgiving Day", etc), 0, 1)

 

where the red font would be the list of specific holidays. I know I could do this with the switch function or repeat a bunch of ||, but I figured I'd ask you all if there's a shorter alternative.

 

Thanks in advance!

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

what you are looking for is the "IN"  keyword. Note it needs curly bracket, unlike in SQL.

 

WorkingDay = IF('DateTable'[Holiday] IN {"Memorial Day", "Thanksgiving Day", etc}, 0, 1)

 

your other question is difficult to answer without seeing the data model.

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks everyone for all the resources!

 

@lbendlin I did think about the IN operator, but wasn't able to get it to work. I did find a way to get around it.

 

As for the first issue, I settled on a solution that required me to create a calculated column to pull in the day after Thanksgiving on the holiday table. Then it was easy to use that column to identify the day after Thanksgiving on the date table.

DayAfterThanksgiving Date = IF( 'Holiday'[Holiday] = "Thanksgiving Day", 'Holiday'[Date]+1, Blank() )

harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

See if this helps.

 

https://community.powerbi.com/t5/Desktop/Public-Holiday-Script/td-p/178341

https://community.powerbi.com/t5/Power-Query/Excluding-School-holidays-from-date-count/m-p/962281

https://community.powerbi.com/t5/Desktop/Dynamic-Holiday-Calendar/m-p/866747

 

You basically need to create a Holiday Table and a Column for your Company Holiday and comapare the two Column.

 

The above link compares Holidays with Weekend, you would need to compare your Company Holidays with all the Major Holidays 

 

Hope this helps.

 

Regards,
Harsh Nathani

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

 

 

lbendlin
Super User
Super User

what you are looking for is the "IN"  keyword. Note it needs curly bracket, unlike in SQL.

 

WorkingDay = IF('DateTable'[Holiday] IN {"Memorial Day", "Thanksgiving Day", etc}, 0, 1)

 

your other question is difficult to answer without seeing the data model.

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors