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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Denis_Slav
Helper III
Helper III

Calendar and column with last period from date

Hello, 

How I can create column in calendar table, where will be marked as "0/1" dstes, which will be in range between DT_Start and DT_End. Where:

DT_End = Last date in dataset table

DT_Start = DT_End with lag for X period (days, month)?

 

Sample of file 

1 ACCEPTED SOLUTION
V-pazhen-msft
Community Support
Community Support

@Denis_Slav 

Try create this column in the calendar table:

 

Column = IF(DIC_Calendar[DT_DATE]>= DS_Value[DT_Maxx] -3 && [DT_DATE] <=DS_Value[DT_Maxx],1,0)

 

For week lags, try:

 

Column = IF(DIC_Calendar[DT_DATE]>= DS_Value[DT_Maxx] -3 && [DT_DATE] <=DS_Value[DT_Maxx],1,0)

 


Paul Zheng _ Community Support Team
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

5 REPLIES 5
V-pazhen-msft
Community Support
Community Support

@Denis_Slav 

Try create this column in the calendar table:

 

Column = IF(DIC_Calendar[DT_DATE]>= DS_Value[DT_Maxx] -3 && [DT_DATE] <=DS_Value[DT_Maxx],1,0)

 

For week lags, try:

 

Column = IF(DIC_Calendar[DT_DATE]>= DS_Value[DT_Maxx] -3 && [DT_DATE] <=DS_Value[DT_Maxx],1,0)

 


Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

V-pazhen-msft
Community Support
Community Support

@Denis_Slav 

Still not clear for me, could you provide the expected output in a table. For now, you need to specify the period unit(Month, Day or Week). 

 

Regards
Paul

@V-pazhen-msft Try to explain on "day" lag.
What I have:

1) Generated calendar

 

DT_Date = {01/01/2019..31/12/2020}

 

2) Data set with last date

 

DT_LastDate = 07/05/2020

 

What I woul like:
1) Mark in Calendar table dates in lag=3 days from DT_LastDate:

 

If 
 ([DT_Date] > ([DT_Last_date] - 3)) && ([DT_Date] <= [DT_LastDate])
Then 1
Else 0

 

What I would like in output:
Table 'Calendar' with custom column with check if date in range

DT_DateCHK
01/05/2020 
02/05/2020 
03/05/2020 
04/05/20201
05/05/20201
06/05/20201
07/05/20201
08/05/2020 
09/05/2020 

 

parry2k
Super User
Super User

@Denis_Slav not fully sure what you mean lag of X? What is X?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k I mean change date to several periods. For example I have date 01/04/2020 and lag for "1 month" give me 01/03/2020, or lag "2 week" give me 18/03/2020.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.