Forum Discussion

gauravnarchal's avatar
gauravnarchal
Post Prodigy
4 years ago
Solved

Count Weekends

I want to count the weekend (Fri & Sat) as of today.  How can I add "as of today" to the below measure so I can get the desired result count 1?

 

_weekendcountasoftoday =

CALCULATE(

    COUNTROWS('Calendar'), all('Calendar'), 'Calendar'[WeekdayWeekend] = "Weekend")

 

Calendar Table

 

MonthYearWeekdayNumberDateWeekdayWeekendWeekday
Apr-22501-04-22 0:00WeekdayFri
Apr-22602-04-22 0:00WeekendSat
Apr-22003-04-22 0:00WeekendSun
Apr-22104-04-22 0:00WeekdayMon
Apr-22205-04-22 0:00WeekdayTue
Apr-22306-04-22 0:00WeekdayWed
Apr-22407-04-22 0:00WeekdayThu
Apr-22508-04-22 0:00WeekdayFri
Apr-22609-04-22 0:00WeekendSat
Apr-22010-04-22 0:00WeekendSun
Apr-22111-04-22 0:00WeekdayMon
Apr-22212-04-22 0:00WeekdayTue
Apr-22313-04-22 0:00WeekdayWed
Apr-22414-04-22 0:00WeekdayThu
Apr-22515-04-22 0:00WeekdayFri
Apr-22616-04-22 0:00WeekendSat
Apr-22017-04-22 0:00WeekendSun
Apr-22118-04-22 0:00WeekdayMon
Apr-22219-04-22 0:00WeekdayTue
Apr-22320-04-22 0:00WeekdayWed
Apr-22421-04-22 0:00WeekdayThu
Apr-22522-04-22 0:00WeekdayFri
Apr-22623-04-22 0:00WeekendSat
Apr-22024-04-22 0:00WeekendSun
Apr-22125-04-22 0:00WeekdayMon
Apr-22226-04-22 0:00WeekdayTue
Apr-22327-04-22 0:00WeekdayWed
Apr-22428-04-22 0:00WeekdayThu
Apr-22529-04-22 0:00WeekdayFri
Apr-22630-04-22 0:00WeekendSat

 

 

  • Hi, gauravnarchal 

     

    You can try the following methods.

    _weekendcountasoftoday = 
    CALCULATE (
        COUNTROWS ( 'Calendar' ),
        FILTER (
            ALL ( 'Calendar' ),
            [WeekdayWeekend] = "Weekend"
                && [Date] <= TODAY ()
                && [Monthyear] = SELECTEDVALUE ( 'Calendar'[Monthyear] )
        )
    )

    The day I replied to you is April 5, and the weekend count should be 2.

    When I replace today with April 2nd as you asked, I get the result you were expecting before with the number 1.

    This should be your desired outcome.

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

6 Replies

  • Hi,

    This measure works

    =CALCULATE(COUNTROWS('Calendar'),'Calendar'[WeekdayWeekend]="Weekend",DATESBETWEEN('Calendar'[Date],MINX(all('Calendar'),'Calendar'[Date]),today()))
    • gauravnarchal's avatar
      gauravnarchal
      Post Prodigy

      Thanks Ashish_Mathur  - It gives me the count of the weekend results as YTD. How can I get the result weekend result for MTD as of today?

       

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        What do you mean by MTD as of today and how can the answer be 26?

  • gauravnarchal 

    maybe try

    CALCULATE(

        COUNTROWS('Calendar'), all('Calendar'), 'Calendar'[WeekdayWeekend] = "Weekend" && ‘Calendar'[Date]<=today() )

    • gauravnarchal's avatar
      gauravnarchal
      Post Prodigy

      Hi ryan_mayu  - I am not getting the result using this measure. When I select the month April’22 in the slicer, I am getting the result as 861 which is YTD instead of 1 as this month (April 22) today is the first weekend.

  • v-zhangti's avatar
    v-zhangti
    Community Support

    Hi, gauravnarchal 

     

    You can try the following methods.

    _weekendcountasoftoday = 
    CALCULATE (
        COUNTROWS ( 'Calendar' ),
        FILTER (
            ALL ( 'Calendar' ),
            [WeekdayWeekend] = "Weekend"
                && [Date] <= TODAY ()
                && [Monthyear] = SELECTEDVALUE ( 'Calendar'[Monthyear] )
        )
    )

    The day I replied to you is April 5, and the weekend count should be 2.

    When I replace today with April 2nd as you asked, I get the result you were expecting before with the number 1.

    This should be your desired outcome.

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.