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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

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
Anonymous
Not applicable

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 @Anonymous 
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

@Anonymous 

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

Anonymous
Not applicable

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 @Anonymous 
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 @Anonymous 
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" )
Anonymous
Not applicable

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.