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
vnanduri
Frequent Visitor

Set flags for Fridays

Hi Team,

 

I have a query as below,

 

My dataset has only Friday dates, So my question is, the most recent friday should be numbered as zero and the preceding fridays should be numbered -1, -2... and so on.

 

For example, since todays' date is 02/06/2020, the data should be like 

 

29-05-2020 - 0

22-05-2020 - (-1)

15-05-2020 - (-2)

 

and so on...

 

I'll be having multiple records for each date.

 

Regards,

Vijay

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @vnanduri ,

You can create a calculated column as below:

Flag = 
VAR Sweek =
    'Date'[Date] - WEEKDAY ( 'Date'[Date], 2 ) + 1
VAR Cweek =
    TODAY () - WEEKDAY ( TODAY (), 2 ) + 1
RETURN
    ( Sweek - Cweek ) / 7 + 1

flag.JPG

Best Regards

Rena

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

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @vnanduri ,

You can create a calculated column as below:

Flag = 
VAR Sweek =
    'Date'[Date] - WEEKDAY ( 'Date'[Date], 2 ) + 1
VAR Cweek =
    TODAY () - WEEKDAY ( TODAY (), 2 ) + 1
RETURN
    ( Sweek - Cweek ) / 7 + 1

flag.JPG

Best Regards

Rena

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

Hi,

 

This works for me.

 

Cheers,

VJ

amitchandak
Super User
Super User

@vnanduri 

Last Friday = today()+-1*if(WEEKDAY(today())-6<0,WEEKDAY(today())+1,WEEKDAY(today())-6)

Last to Last Friday = today()+-1*if(WEEKDAY(today())-6<0,WEEKDAY(today())+1,WEEKDAY(today())-6) -7

 

keep on getting subtracting -7 to get more

You can actually use date diff from Last Friday  and take mod(reminder) or quotient of that with 7 to get the desired result

 

quotient (datediff(Date[Date],[Last Friday],day),7)

mod(datediff(Date[Date],[Last Friday],day),7)

tex628
Community Champion
Community Champion

Create a column:

Column = (RANKX('Table';'Table'[Date];'Table'[Date];DESC;Dense) -1) * -1



/ J


Connect on LinkedIn

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.