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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
AMar22
Frequent Visitor

Week Number parameters

Hi,

 

I'm working on a weekly production plan, I created a date table with the week numbers (Formula: Weeknum)
My working week starts on Sunday and ends on Saturday.

 

There are weeks that are situated in 2 months

              Example 01: Week 32 , start in Sunday 31/07/2022 ,ends 06/08/2022  , 1 day in July and  6 days in August  . In this case                                                                  Dax considered this week in July --it's not correct for me

 

I want to apply this parameter when retrieving the week number in case the week is situated in 2 different months.

- (Case Example 01) The Week 32 will be conidered in July if the number of days of this week are =>3 are in July , else considere in August.

How I can do this ?

 

 

AMar22_0-1659883412154.png

 

 

2 ACCEPTED SOLUTIONS

Thank you @tamerj1  for your reponse.

just one detail ,how I can convert "Slicer Month" to a Date Format, now it is a Text ?

View solution in original post

Hi @AMar22 
Create another column (Slicer Month Number) and then use the option sort by column to sort the Slicer Month by the Slicer Month Number

Slicer Month = 
VAR CurrentMonth = 'Date'[Month Number]
VAR CurrentYearWeekTable =
    FILTER (
        CALCULATETABLE ( 'Date', ALLEXCEPT ( 'Date', 'Date'[Year], 'Date'[Week Number] ) ),
        'Date'[Month Number] = CurrentMonth
    )
VAR MaxWeekday = 
    MAXX ( CurrentYearWeekTable, WEEKDAY ( 'Date'[Date], 1 ) )
VAR MonthNumber =
    IF (
        MaxWeekday < 3, 
        CurrentMonth + 1,
        CurrentMonth
    )
RETURN
    MonthNumber

View solution in original post

5 REPLIES 5
tamerj1
Super User
Super User

@AMar22 

Do you mean you want to show the first or last day of the month?

Hi @tamerj1 ,I mean to put slicer in descending order in the visual (report) like: January, February, March.....SO I must put the format as a dat

 

Hi @AMar22 
Create another column (Slicer Month Number) and then use the option sort by column to sort the Slicer Month by the Slicer Month Number

Slicer Month = 
VAR CurrentMonth = 'Date'[Month Number]
VAR CurrentYearWeekTable =
    FILTER (
        CALCULATETABLE ( 'Date', ALLEXCEPT ( 'Date', 'Date'[Year], 'Date'[Week Number] ) ),
        'Date'[Month Number] = CurrentMonth
    )
VAR MaxWeekday = 
    MAXX ( CurrentYearWeekTable, WEEKDAY ( 'Date'[Date], 1 ) )
VAR MonthNumber =
    IF (
        MaxWeekday < 3, 
        CurrentMonth + 1,
        CurrentMonth
    )
RETURN
    MonthNumber
tamerj1
Super User
Super User

Hi @AMar22 
Here is a sample file with the solution https://www.dropbox.com/t/SfZdZRuR9IMEblZN

You need to create a new month column in the date table to use as slicer, as follows:

Slicer Month = 
VAR CurrentMonth = 'Date'[Month Number]
VAR CurrentYearWeekTable =
    FILTER (
        CALCULATETABLE ( 'Date', ALLEXCEPT ( 'Date', 'Date'[Year], 'Date'[Week Number] ) ),
        'Date'[Month Number] = CurrentMonth
    )
VAR MaxWeekday = 
    MAXX ( CurrentYearWeekTable, WEEKDAY ( 'Date'[Date], 1 ) )
VAR MonthNumber =
    IF (
        MaxWeekday < 3, 
        CurrentMonth + 1,
        CurrentMonth
    )
RETURN
    FORMAT ( DATE ( 1, MonthNumber, 1 ), "MMMM" )

Thank you @tamerj1  for your reponse.

just one detail ,how I can convert "Slicer Month" to a Date Format, now it is a Text ?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.