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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
rebam12
Helper I
Helper I

current month weekly data

hi 

 

i am trying to get current month weekly data .. i tried this formula but still i did not get it current month weekly data .. \

 

 

Week_Ranges3 = 
VAR CurrentDate = 'Export'[Dispatch Date (End)]
VAR CurrentMonthStart = DATE(YEAR(CurrentDate), MONTH(CurrentDate), 1) -- First day of the current month
VAR CurrentMonthEnd = EOMONTH(CurrentDate, 0) -- Last day of the current month
VAR WeekStart = CurrentDate - WEEKDAY(CurrentDate, 2) + 1 -- Week starts on Monday
VAR WeekEnd = WeekStart + 6 -- Week ends on Sunday
VAR AdjustedWeekStart = MAX(WeekStart, CurrentMonthStart) -- Clamp to the month's start
VAR AdjustedWeekEnd = MIN(WeekEnd, CurrentMonthEnd) -- Clamp to the month's end
RETURN
    IF(
        AdjustedWeekStart <= CurrentMonthEnd && AdjustedWeekEnd >= CurrentMonthStart, 
        CONCATENATE(
            CONCATENATE(YEAR(AdjustedWeekStart), "/" & MONTH(AdjustedWeekStart) & "/" & DAY(AdjustedWeekStart)),
            " - " & YEAR(AdjustedWeekEnd) & "/" & MONTH(AdjustedWeekEnd) & "/" & DAY(AdjustedWeekEnd)
        ),
        BLANK()
    )

 

this is the data with dates

 

https://filetransfer.io/data-package/t8GhECJ4#link

where is the error 

1 ACCEPTED SOLUTION

@rebam12 Since you have an Excel file with a column named "Dispatch Date" and you want to calculate the weekly ranges for the current month, you can use the following DAX formula to create a calculated column in Power BI:

 

Week_Ranges3 =
VAR CurrentDate = TODAY()
VAR CurrentMonthStart = DATE(YEAR(CurrentDate), MONTH(CurrentDate), 1) -- First day of the current month
VAR CurrentMonthEnd = EOMONTH(CurrentDate, 0) -- Last day of the current month
VAR WeekStart = CurrentMonthStart + (7 - WEEKDAY(CurrentMonthStart, 2)) % 7 -- First Monday of the current month
VAR WeekEnd = WeekStart + 6 -- First Sunday of the current month
VAR AdjustedWeekStart = MAX(WeekStart, 'Export'[Dispatch Date (End)] - WEEKDAY('Export'[Dispatch Date (End)], 2) + 1)
VAR AdjustedWeekEnd = MIN(AdjustedWeekStart + 6, CurrentMonthEnd)
RETURN
IF(
'Export'[Dispatch Date (End)] >= CurrentMonthStart && 'Export'[Dispatch Date (End)] <= CurrentMonthEnd,
CONCATENATE(
CONCATENATE(YEAR(AdjustedWeekStart), "/" & MONTH(AdjustedWeekStart) & "/" & DAY(AdjustedWeekStart)),
" - " & YEAR(AdjustedWeekEnd) & "/" & MONTH(AdjustedWeekEnd) & "/" & DAY(AdjustedWeekEnd)
),
BLANK()
)

 

But still ideal way is to use date table




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

6 REPLIES 6
bhanu_gautam
Super User
Super User

@rebam12 , Try using 

 

Week_Ranges3 =
VAR CurrentDate = TODAY() -- Use TODAY() to get the current date
VAR CurrentMonthStart = DATE(YEAR(CurrentDate), MONTH(CurrentDate), 1) -- First day of the current month
VAR CurrentMonthEnd = EOMONTH(CurrentDate, 0) -- Last day of the current month
VAR WeekStart = CurrentMonthStart -- Start from the first day of the current month
VAR WeekEnd = WeekStart + 6 -- Week ends on the 7th day from the start
VAR Result =
ADDCOLUMNS(
GENERATESERIES(0, DATEDIFF(CurrentMonthStart, CurrentMonthEnd, DAY) / 7, 1),
"WeekStart", WeekStart + [Value] * 7,
"WeekEnd", MIN(WeekStart + [Value] * 7 + 6, CurrentMonthEnd)
)
RETURN
CONCATENATEX(
Result,
CONCATENATE(
CONCATENATE(YEAR([WeekStart]), "/" & MONTH([WeekStart]) & "/" & DAY([WeekStart])),
" - " & YEAR([WeekEnd]) & "/" & MONTH([WeekEnd]) & "/" & DAY([WeekEnd])
),
", "
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






got an eror Cannot find table 'DateTable'.

@rebam12 , It looks like you do not have Date Table created go to modelling tab and create a new date table using below DAX

DateTable =
ADDCOLUMNS (
    CALENDAR (DATE(2023, 1, 1), DATE(2023, 12, 31)),
    "Year", YEAR([Date]),
    "Month", MONTH([Date]),
    "Day", DAY([Date]),
    "MonthName", FORMAT([Date], "MMMM"),
    "Quarter", "Q" & FORMAT([Date], "Q")
)
 
And than create a relationship with your original table



Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@rebam12 Since you have an Excel file with a column named "Dispatch Date" and you want to calculate the weekly ranges for the current month, you can use the following DAX formula to create a calculated column in Power BI:

 

Week_Ranges3 =
VAR CurrentDate = TODAY()
VAR CurrentMonthStart = DATE(YEAR(CurrentDate), MONTH(CurrentDate), 1) -- First day of the current month
VAR CurrentMonthEnd = EOMONTH(CurrentDate, 0) -- Last day of the current month
VAR WeekStart = CurrentMonthStart + (7 - WEEKDAY(CurrentMonthStart, 2)) % 7 -- First Monday of the current month
VAR WeekEnd = WeekStart + 6 -- First Sunday of the current month
VAR AdjustedWeekStart = MAX(WeekStart, 'Export'[Dispatch Date (End)] - WEEKDAY('Export'[Dispatch Date (End)], 2) + 1)
VAR AdjustedWeekEnd = MIN(AdjustedWeekStart + 6, CurrentMonthEnd)
RETURN
IF(
'Export'[Dispatch Date (End)] >= CurrentMonthStart && 'Export'[Dispatch Date (End)] <= CurrentMonthEnd,
CONCATENATE(
CONCATENATE(YEAR(AdjustedWeekStart), "/" & MONTH(AdjustedWeekStart) & "/" & DAY(AdjustedWeekStart)),
" - " & YEAR(AdjustedWeekEnd) & "/" & MONTH(AdjustedWeekEnd) & "/" & DAY(AdjustedWeekEnd)
),
BLANK()
)

 

But still ideal way is to use date table




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






i already mentioned.. i have a file .. excel file  which i import in power bi .. and column name is dispatch date.. i already shared the link of file . ..

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.