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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
bernate
Helper III
Helper III

New column that checks if date is in multiple dynamic date ranges

Hello, I have a list of dates I would like to use as slicer selections.  

 

bernate_0-1714427572065.png

 

I am using 2 tables- Date and Product Archive. The Product Archive table has 2 date columns- a Start Date and an Archive Date. The Date table has a DtKey column. I want to add a column to the Date table that would have the associated Start Date. So for example, in the Date table, all dates that fall between 02/21/2019 and 09/08/2021 should have "02/21/2019" listed in the new column, all dates between 09/09/2019 and 11/03/2019 should have "09/09/2019" listed in the new column.

 

I can do this manually with the code below, but I want this to be dynamic so that when a new Start Date gets added to the Product Archive, Power BI will also update accordingly.

if [DtKey] >= #date(2000,01,01) and [DtKey] < #date(2019,02,21) then "01/01/2000" else 
if [DtKey] >= #date(2019,02,21) and [DtKey] < #date(2019,09,09) then "02/21/2019" else "Next"
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @bernate ,

 

Really happy to help you solve this. Here's my solution below.

1.Go through a few steps to get the next date.(reference:Value from previous row )

vstephenmsft_0-1714544682834.png

 

2.In Date Table, reference the start date field and the next start date field from Product Archive table.

vstephenmsft_1-1714544791020.png

 

3.Expand it.

vstephenmsft_2-1714544809841.png

 

4.Create below custom for filtering. Filter out 1.

vstephenmsft_3-1714545788843.pngvstephenmsft_4-1714545799270.png

And here's your final column you want.

vstephenmsft_5-1714545865059.png

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
bernate
Helper III
Helper III

Thank you for your help Stephen!

Anonymous
Not applicable

Hi @bernate ,

 

Really happy to help you solve this. Here's my solution below.

1.Go through a few steps to get the next date.(reference:Value from previous row )

vstephenmsft_0-1714544682834.png

 

2.In Date Table, reference the start date field and the next start date field from Product Archive table.

vstephenmsft_1-1714544791020.png

 

3.Expand it.

vstephenmsft_2-1714544809841.png

 

4.Create below custom for filtering. Filter out 1.

vstephenmsft_3-1714545788843.pngvstephenmsft_4-1714545799270.png

And here's your final column you want.

vstephenmsft_5-1714545865059.png

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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