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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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