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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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(...)



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@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(...)



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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