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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Working Days for any given month/period

Hi Experts.

 

How could i work out the number of working days for any given month for any of my four countries - so if i select October on Slicer it gives me the correct number of WD for October for

 

1. Ireland

2. Tawain

3. India

4. USA in a central matrix table.....

 

The attached images show calander dat i have scrb from a website...

Capture.PNG

 

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

You can try to use below measure to calculate working days:

Measure =
VAR workdaylist =
    CALCULATETABLE (
        VALUES ( DimDate[Date] ),
        WEEKDAY ( DimDate[Date], 1 ) IN GENERATESERIES ( 2, 6, 1 )
    )
VAR holiday =
    CALCULATETABLE (
        VALUES ( 'Taiwan Calendar'[Date] ),
        ALLSELECTED ( 'Taiwan Calendar' ),
        VALUES ( 'Taiwan Calendar'[Country] )
    )
RETURN
    COUNTROWS ( EXCEPT ( workdaylist, holiday ) )

19.PNG

 

>> i have a measure in column Workingdays table Taiwan Calender...which is not correct,

AFAIK, current power bi not support to create dynamic calculated column/table based on slicer/filter.

 

BTW, I haven't found any country filters in your sample, how did your filter on it?

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

7 REPLIES 7
PattemManohar
Community Champion
Community Champion

@Anonymous Please try this... I've used the "Date" dimension table in-addition to the "Holidays" table

 

WorkingDays = 

VAR CWD = CALCULATE(COUNT(DateTable[DateKey]),FILTER(DateTable,DateTable[DayOfWeekNo] <> 1 && DateTable[DayOfWeekNo] <> 7 && VALUE(DateTable[MonthNo]) = MONTH(EARLIER(Holidays[Date]))))
VAR Hol = CALCULATE(COUNT(Holidays[Date]),FILTER(ALL(Holidays),MONTH(Holidays[Date])=MONTH(EARLIER(Holidays[Date])) && Holidays[Country] = EARLIER(Holidays[Country]) && Holidays[WeekDay] <> "Saturday" && Holidays[WeekDay] <> "Sunday"))

RETURN CWD - Hol

 

image.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a PBI Community Champion




Anonymous
Not applicable

Hi pattenmanhar 

Thanks for the feedback do you have your sample pbix file....i have just tried your formula and not getting the same end result.

HI @Anonymous,

 

Can you please share some sample data for test and coding formula?

 

BTW, you can also try to use belwo formula if it works for your requirment:

working days except weekend and holiday =
VAR endDate =
    IF ( Table[End] <> BLANK (), Table[End], TODAY () )
VAR _calendar =
    FILTER ( CALENDAR ( Table[Start], endDate ), WEEKDAY ( [Date], 2 ) <= 5 ) //calendar wihtout weekend
VAR _holidayList =
    CALCULATE (
        VALUES ( Holiday[Date] ),
        FILTER ( ALLSELECTED ( Holiday ), Holiday[AREA] IN VALUES ( Table[AREA] ) )
    ) //holiday date list
RETURN
    IF (
        COUNTROWS ( _holidayList ) > 0,
        COUNTROWS ( EXCEPT ( _calendar, _holidayList ) ),
        COUNTROWS ( _calendar )
    )

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Sheng. i have a measure in column Workingdays table Taiwan Calender...which is not correct,

Hi @Anonymous,

 

You can try to use below measure to calculate working days:

Measure =
VAR workdaylist =
    CALCULATETABLE (
        VALUES ( DimDate[Date] ),
        WEEKDAY ( DimDate[Date], 1 ) IN GENERATESERIES ( 2, 6, 1 )
    )
VAR holiday =
    CALCULATETABLE (
        VALUES ( 'Taiwan Calendar'[Date] ),
        ALLSELECTED ( 'Taiwan Calendar' ),
        VALUES ( 'Taiwan Calendar'[Country] )
    )
RETURN
    COUNTROWS ( EXCEPT ( workdaylist, holiday ) )

19.PNG

 

>> i have a measure in column Workingdays table Taiwan Calender...which is not correct,

AFAIK, current power bi not support to create dynamic calculated column/table based on slicer/filter.

 

BTW, I haven't found any country filters in your sample, how did your filter on it?

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

Hi Sheng

 

Thats the next stage....this is sam.le data i sent across and also many thanks for the excellent feedback.

Anonymous
Not applicable

Sheng see link. File in drop box.

 

The file has two tables a dim date and Taiwan holidays calendar I want to work out the measure as per your post.https://www.dropbox.com/s/sy8h2njxsnhzwvb/Testfile-HMDRMvaVg03lviJAYLhElsM9CHCD9pHYE0QAQPOPrNSacGy2j...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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