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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
J_Zayak
Frequent Visitor

Prevent end of week data from splitting between to months

Greetings all, I'm scratching my head trying to figure out how to essentially "roll forward" data into the next month if the end of week falls in that month.

J_Zayak_0-1644889785990.png

 The rows in the 'Sales' contain the $ amount and the date (1/3/2022 etc). The calendar table has an EOW column and the relationship is between the 'Sales' date and calendar date. 

 

Using the example above, I would want the EOW data for 1/2/2022 to fall in January, not split between the two months. 2/6/2022 would fall into Febuary only, etc.

 

example tables:

SALES

DateKeySales
12/27/2021500
12/28/2021600
12/31/20211000
1/1/20221500
1/2/2022700

 

CALENDAR

DateMonthYearEOW
12/27/20211220211/2/2022
12/28/20211220211/2/2022
12/29/20211220211/2/2022
12/30/20211220211/2/2022
12/31/20211220211/2/2022
1/1/20221220221/2/2022
1/2/20221220221/2/2022

 

Thanks in advance, hope this makes sense and I've provided enough data.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@J_Zayak , For That either display data week wise of create week month on week start date or week end date

 

Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],1)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],1)

 

Month Year = format([Week Start Date],"MMM-YYYY")

or

Month Year = format([Week END Date],"MMM-YYYY")

 

Month Year Sort= format([Week Start Date],"YYYYMM")

or

Month Year Sort= format([Week END Date],"YYYYMM")

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

Simple enough, just keep the "Month" symbol of a whole week the same as the start of the week,

CNENFRNL_0-1644898094387.png

 

let
    Source = Table.FromList(List.Dates(#date(2021, 12, 27), 10, #duration(1, 0, 0, 0)), Splitter.SplitByNothing(), {"Date"}),
    EoW = Table.AddColumn(Source, "EoW", each Date.EndOfWeek([Date],Day.Monday)),
    
    #"Virtual Month" = Table.AddColumn(EoW, "Virtual Month", each Date.ToText(Date.StartOfWeek([Date]), "MMM yyyy"))

in
    #"Virtual Month"

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

amitchandak
Super User
Super User

@J_Zayak , For That either display data week wise of create week month on week start date or week end date

 

Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],1)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],1)

 

Month Year = format([Week Start Date],"MMM-YYYY")

or

Month Year = format([Week END Date],"MMM-YYYY")

 

Month Year Sort= format([Week Start Date],"YYYYMM")

or

Month Year Sort= format([Week END Date],"YYYYMM")

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

This is the way. Thank you

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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