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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Rakeshss
Frequent Visitor

If the date is not equal to Monday I want next Monday of the Week

Team,

If my date is not equal to monday then I want next weeks Monday date, how to achieve this.

Rakeshss_0-1715711120366.png

Here my out put is 02/14/2024 which is Wednesday so I want 02/19/2024.

If my out put date was 02/12/2024 as its Monday I want the it as it is.

Please help me.

 

Thanks!

Rakesh

2 ACCEPTED SOLUTIONS
AnalyticPulse
Impactful Individual
Impactful Individual

Try this dax:

NextMonday =

VAR CurrentDate = MAX(EU_OMP_PROD_LOC_PLANVIEN_DAILYFACT[SNAPSHOT_DATE ])

VAR DayOfWeek = WEEKDAY(CurrentDate, 2)

 

VAR DaysToAdd = IF(DayOfWeek <> 1, 8 - DayOfWeek, 0)

 

RETURN CurrentDate + DaysToAdd

 

learn more about dashboard and domain on below blog:

 

https://analyticpulse.blogspot.com

 

View solution in original post

v-huijiey-msft
Community Support
Community Support

Hi @Rakeshss ,

 

Thanks for the reply from @AnalyticPulse .

 

In Power Query:

 

Enter the following code:

= let
    InputDate = #date(2024,2,14),
    DayOfWeek = Date.DayOfWeek(InputDate, Day.Monday),
    DaysToAdd = if DayOfWeek = 0 then 0 else 7 - DayOfWeek,
    NextMonday = Date.AddDays(InputDate, DaysToAdd)
in
    NextMonday

 

The page effect is shown below.

vhuijieymsft_0-1715831646314.png

 

There is a downside to this, the date is hard coded.

 

So I created some sample data:

2024/5/12

2024/5/13

2024/5/14

2024/5/15

2024/5/16

2024/5/17

2024/5/18

2024/5/19

2024/5/20

 

Create a custom column with the following syntax:

if Date.DayOfWeek([Date], Day.Monday) = 0 then [Date] else Date.AddDays([Date], 7 - Date.DayOfWeek([Date], Day.Monday))

vhuijieymsft_1-1715831646315.png

vhuijieymsft_2-1715831654780.png

 

The page effect is shown below.

vhuijieymsft_3-1715831654781.png

vhuijieymsft_4-1715831666713.png

 

The pbix file is attached.

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

4 REPLIES 4
v-huijiey-msft
Community Support
Community Support

Hi @Rakeshss ,

 

Thanks for the reply from @AnalyticPulse .

 

In Power Query:

 

Enter the following code:

= let
    InputDate = #date(2024,2,14),
    DayOfWeek = Date.DayOfWeek(InputDate, Day.Monday),
    DaysToAdd = if DayOfWeek = 0 then 0 else 7 - DayOfWeek,
    NextMonday = Date.AddDays(InputDate, DaysToAdd)
in
    NextMonday

 

The page effect is shown below.

vhuijieymsft_0-1715831646314.png

 

There is a downside to this, the date is hard coded.

 

So I created some sample data:

2024/5/12

2024/5/13

2024/5/14

2024/5/15

2024/5/16

2024/5/17

2024/5/18

2024/5/19

2024/5/20

 

Create a custom column with the following syntax:

if Date.DayOfWeek([Date], Day.Monday) = 0 then [Date] else Date.AddDays([Date], 7 - Date.DayOfWeek([Date], Day.Monday))

vhuijieymsft_1-1715831646315.png

vhuijieymsft_2-1715831654780.png

 

The page effect is shown below.

vhuijieymsft_3-1715831654781.png

vhuijieymsft_4-1715831666713.png

 

The pbix file is attached.

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

AnalyticPulse
Impactful Individual
Impactful Individual

Yes just use the same logic as above dax

AnalyticPulse
Impactful Individual
Impactful Individual

Try this dax:

NextMonday =

VAR CurrentDate = MAX(EU_OMP_PROD_LOC_PLANVIEN_DAILYFACT[SNAPSHOT_DATE ])

VAR DayOfWeek = WEEKDAY(CurrentDate, 2)

 

VAR DaysToAdd = IF(DayOfWeek <> 1, 8 - DayOfWeek, 0)

 

RETURN CurrentDate + DaysToAdd

 

learn more about dashboard and domain on below blog:

 

https://analyticpulse.blogspot.com

 

@AnalyticPulse , 

Thanks for your response, can I do the same in M Query ?

 

 

Thanks

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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