cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ThusiHettigama
Regular Visitor

Current Month Working days calculation

My objective is to calculate the number of working days up until yesterday for the current month.

The below measure is working in the Desktop version. However, once it is published not calculating in the Web version.

 

dimCalendar is a table in PowerBI. IsCurrentMonth and IsWeekDay are columns in the dimCalendar table.

 

CurrentMonthworkingDays =

CALCULATE (

    COUNTROWS (dimCalendar),

    FILTER (

        dimCalendar,

        dimCalendar[Day] <= DAY ( TODAY ()-1 )

            && dimCalendar[IsCurrentMonth]=1

            && dimCalendar[IsWeekDay]="True"))

1 ACCEPTED SOLUTION

@ThusiHettigama Try using a VAR then. 

VAR __Day = DAY(UTCTODAY()-1)

RETURN

COUNTROWS(...)


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop!
Microsoft Hates Greg's Quick Measures
Check out my latest book!

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

@ThusiHettigama Maybe try UTCTODAY instead of TODAY?

UTCTODAY function (DAX) - DAX | Microsoft Docs


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop!
Microsoft Hates Greg's Quick Measures
Check out my latest book!

Greg,  Thanks for suggesting a solution for my issue. However after using UTCTODAY function, the issue is still occuring 

@ThusiHettigama Hmm, try placing a simple measure like Measure = TODAY() into a Card visualization and see if you get a different value based upon the Desktop or the Service. Wondering if you need to do some kind of TZ conversion.


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop!
Microsoft Hates Greg's Quick Measures
Check out my latest book!

@Greg_Deckler 

 

Measure = DAY(UTCTODAY()-1) is working in the Desktop version and the Service. However when I add COUNTROWS to calculate number of working days from first day of the current month to DAY(UTCTODAY()-1) it's breaking in the Service (published version)

@ThusiHettigama Try using a VAR then. 

VAR __Day = DAY(UTCTODAY()-1)

RETURN

COUNTROWS(...)


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop!
Microsoft Hates Greg's Quick Measures
Check out my latest book!

View solution in original post

@Greg_Deckler Thank you very much for the support. Appreciated !! 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!