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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
bernate
Advocate I
Advocate I

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
v-stephen-msft
Community Support
Community Support

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
Advocate I
Advocate I

Thank you for your help Stephen!

v-stephen-msft
Community Support
Community Support

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors