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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

count of Number of selling days until previous day for a month without using day slicer

Hi Everyone,

 

I'm struggling to get the count of selling days until previous day after removing weekends and holidays.

For Eg: If we take the current month , number of selling days should come to 4( I dont want to consider today), total numbe of selling days should coem to 22, YTD number of selling days should come to 150 and YTD TOTAL Number of selling day should come to 168. I was able to get 22  using measure

Total_NBR_SELLING_DAYS = TOTALMTD(SUM('RunRate Days'[COUNT]),'RunRate Days'[CALENDAR_DATE])
 
and 168 using  measure
Total_YTD_NBR_SELLING_DAYS = COUNTROWS(DATESYTD('RunRate Days'[CALENDAR_DATE])).
 
I am sharing the data set below.
 
TIA

 

 

 

CALENDAR_YEAR_NUMBER	MONTH_COUNT	CALENDAR_DATE	COUNT
2022	1	1/3/2022	1
2022	1	1/4/2022	1
2022	1	1/5/2022	1
2022	1	1/6/2022	1
2022	1	1/7/2022	1
2022	1	1/10/2022	1
2022	1	1/11/2022	1
2022	1	1/12/2022	1
2022	1	1/13/2022	1
2022	1	1/14/2022	1
2022	1	1/17/2022	1
2022	1	1/18/2022	1
2022	1	1/19/2022	1
2022	1	1/20/2022	1
2022	1	1/21/2022	1
2022	1	1/24/2022	1
2022	1	1/25/2022	1
2022	1	1/26/2022	1
2022	1	1/27/2022	1
2022	1	1/28/2022	1
2022	1	1/31/2022	1
2022	2	2/1/2022	1
2022	2	2/2/2022	1
2022	2	2/3/2022	1
2022	2	2/4/2022	1
2022	2	2/7/2022	1
2022	2	2/8/2022	1
2022	2	2/9/2022	1
2022	2	2/10/2022	1
2022	2	2/11/2022	1
2022	2	2/14/2022	1
2022	2	2/15/2022	1
2022	2	2/16/2022	1
2022	2	2/17/2022	1
2022	2	2/18/2022	1
2022	2	2/22/2022	1
2022	2	2/23/2022	1
2022	2	2/24/2022	1
2022	2	2/25/2022	1
2022	2	2/28/2022	1
2022	3	3/1/2022	1
2022	3	3/2/2022	1
2022	3	3/3/2022	1
2022	3	3/4/2022	1
2022	3	3/7/2022	1
2022	3	3/8/2022	1
2022	3	3/9/2022	1
2022	3	3/10/2022	1
2022	3	3/11/2022	1
2022	3	3/14/2022	1
2022	3	3/15/2022	1
2022	3	3/16/2022	1
2022	3	3/17/2022	1
2022	3	3/18/2022	1
2022	3	3/21/2022	1
2022	3	3/22/2022	1
2022	3	3/23/2022	1
2022	3	3/24/2022	1
2022	3	3/25/2022	1
2022	3	3/28/2022	1
2022	3	3/29/2022	1
2022	3	3/30/2022	1
2022	3	3/31/2022	1
2022	4	4/1/2022	1
2022	4	4/4/2022	1
2022	4	4/5/2022	1
2022	4	4/6/2022	1
2022	4	4/7/2022	1
2022	4	4/8/2022	1
2022	4	4/11/2022	1
2022	4	4/12/2022	1
2022	4	4/13/2022	1
2022	4	4/14/2022	1
2022	4	4/18/2022	1
2022	4	4/19/2022	1
2022	4	4/20/2022	1
2022	4	4/21/2022	1
2022	4	4/22/2022	1
2022	4	4/25/2022	1
2022	4	4/26/2022	1
2022	4	4/27/2022	1
2022	4	4/28/2022	1
2022	4	4/29/2022	1
2022	5	5/2/2022	1
2022	5	5/3/2022	1
2022	5	5/4/2022	1
2022	5	5/5/2022	1
2022	5	5/6/2022	1
2022	5	5/9/2022	1
2022	5	5/10/2022	1
2022	5	5/11/2022	1
2022	5	5/12/2022	1
2022	5	5/13/2022	1
2022	5	5/16/2022	1
2022	5	5/17/2022	1
2022	5	5/18/2022	1
2022	5	5/19/2022	1
2022	5	5/20/2022	1
2022	5	5/24/2022	1
2022	5	5/25/2022	1
2022	5	5/26/2022	1
2022	5	5/27/2022	1
2022	5	5/30/2022	1
2022	5	5/31/2022	1
2022	6	6/1/2022	1
2022	6	6/2/2022	1
2022	6	6/3/2022	1
2022	6	6/6/2022	1
2022	6	6/7/2022	1
2022	6	6/8/2022	1
2022	6	6/9/2022	1
2022	6	6/10/2022	1
2022	6	6/13/2022	1
2022	6	6/14/2022	1
2022	6	6/15/2022	1
2022	6	6/16/2022	1
2022	6	6/17/2022	1
2022	6	6/20/2022	1
2022	6	6/21/2022	1
2022	6	6/22/2022	1
2022	6	6/23/2022	1
2022	6	6/24/2022	1
2022	6	6/27/2022	1
2022	6	6/28/2022	1
2022	6	6/29/2022	1
2022	6	6/30/2022	1
2022	7	7/4/2022	1
2022	7	7/5/2022	1
2022	7	7/6/2022	1
2022	7	7/7/2022	1
2022	7	7/8/2022	1
2022	7	7/11/2022	1
2022	7	7/12/2022	1
2022	7	7/13/2022	1
2022	7	7/14/2022	1
2022	7	7/15/2022	1
2022	7	7/18/2022	1
2022	7	7/19/2022	1
2022	7	7/20/2022	1
2022	7	7/21/2022	1
2022	7	7/22/2022	1
2022	7	7/25/2022	1
2022	7	7/26/2022	1
2022	7	7/27/2022	1
2022	7	7/28/2022	1
2022	7	7/29/2022	1
2022	8	8/2/2022	1
2022	8	8/3/2022	1
2022	8	8/4/2022	1
2022	8	8/5/2022	1
2022	8	8/8/2022	1
2022	8	8/9/2022	1
2022	8	8/10/2022	1
2022	8	8/11/2022	1
2022	8	8/12/2022	1
2022	8	8/15/2022	1
2022	8	8/16/2022	1
2022	8	8/17/2022	1
2022	8	8/18/2022	1
2022	8	8/19/2022	1
2022	8	8/22/2022	1
2022	8	8/23/2022	1
2022	8	8/24/2022	1
2022	8	8/25/2022	1
2022	8	8/26/2022	1
2022	8	8/29/2022	1
2022	8	8/30/2022	1
2022	8	8/31/2022	1
2022	9	9/1/2022	1
2022	9	9/2/2022	1
2022	9	9/6/2022	1
2022	9	9/7/2022	1
2022	9	9/8/2022	1
2022	9	9/9/2022	1
2022	9	9/12/2022	1
2022	9	9/13/2022	1
2022	9	9/14/2022	1
2022	9	9/15/2022	1
2022	9	9/16/2022	1
2022	9	9/19/2022	1
2022	9	9/20/2022	1
2022	9	9/21/2022	1
2022	9	9/22/2022	1
2022	9	9/23/2022	1
2022	9	9/26/2022	1
2022	9	9/27/2022	1
2022	9	9/28/2022	1
2022	9	9/29/2022	1
2022	9	9/30/2022	1
2022	10	10/3/2022	1
2022	10	10/4/2022	1
2022	10	10/5/2022	1
2022	10	10/6/2022	1
2022	10	10/7/2022	1
2022	10	10/11/2022	1
2022	10	10/12/2022	1
2022	10	10/13/2022	1
2022	10	10/14/2022	1
2022	10	10/17/2022	1
2022	10	10/18/2022	1
2022	10	10/19/2022	1
2022	10	10/20/2022	1
2022	10	10/21/2022	1
2022	10	10/24/2022	1
2022	10	10/25/2022	1
2022	10	10/26/2022	1
2022	10	10/27/2022	1
2022	10	10/28/2022	1
2022	10	10/31/2022	1
2022	11	11/1/2022	1
2022	11	11/2/2022	1
2022	11	11/3/2022	1
2022	11	11/4/2022	1
2022	11	11/7/2022	1
2022	11	11/8/2022	1
2022	11	11/9/2022	1
2022	11	11/10/2022	1
2022	11	11/11/2022	1
2022	11	11/14/2022	1
2022	11	11/15/2022	1
2022	11	11/16/2022	1
2022	11	11/17/2022	1
2022	11	11/18/2022	1
2022	11	11/21/2022	1
2022	11	11/22/2022	1
2022	11	11/23/2022	1
2022	11	11/24/2022	1
2022	11	11/25/2022	1
2022	11	11/28/2022	1
2022	11	11/29/2022	1
2022	11	11/30/2022	1
2022	12	12/1/2022	1
2022	12	12/2/2022	1
2022	12	12/5/2022	1
2022	12	12/6/2022	1
2022	12	12/7/2022	1
2022	12	12/8/2022	1
2022	12	12/9/2022	1
2022	12	12/12/2022	1
2022	12	12/13/2022	1
2022	12	12/14/2022	1
2022	12	12/15/2022	1
2022	12	12/16/2022	1
2022	12	12/19/2022	1
2022	12	12/20/2022	1
2022	12	12/21/2022	1
2022	12	12/22/2022	1
2022	12	12/23/2022	1
2022	12	12/26/2022	1
2022	12	12/27/2022	1
2022	12	12/28/2022	1
2022	12	12/29/2022	1
2022	12	12/30/2022	1

 

 

 

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Please try:

Until Yesterday NBR_SELLING_DAYS = 
VAR _day =
    TODAY() - 2
VAR _month =
    MONTH ( _day )
VAR _result =
    CALCULATE (
        COUNT ( 'RunRate Days'[COUNT] ),
        FILTER (
            ALL('RunRate Days'),
            'RunRate Days'[CALENDAR_DATE] <= _day
                && 'RunRate Days'[MONTH_COUNT] = _month
        )
    )
RETURN
    _result
YTD number of selling days = 
VAR _day =
    TODAY() - 2
VAR _month =
    MONTH ( _day )
VAR _result =
    CALCULATE (
        COUNT ( 'RunRate Days'[COUNT] ),
        FILTER (
            ALL('RunRate Days'),
            'RunRate Days'[CALENDAR_DATE] <= _day
        )
    )
RETURN
    _result

vcgaomsft_0-1660903685207.png

The PBIX file is attached for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

View solution in original post

5 REPLIES 5
changqing
Resolver II
Resolver II

Hi @Anonymous ,

 

Please try:

 

number of selling days = 
VAR _pre_day =
    MAX ( 'RunRate Days'[CALENDAR_DATE] ) - 1
VAR _month =
    MONTH ( _pre_day )
VAR _result =
    CALCULATE (
        COUNT ( 'RunRate Days'[COUNT] ),
        FILTER (
            ALL('RunRate Days'),
            'RunRate Days'[CALENDAR_DATE] <= _pre_day
                && 'RunRate Days'[MONTH_COUNT] = _month
        )
    ) + 0
RETURN
    _result
YTD number of selling days = 
VAR _pre_day =
    MAX ( 'RunRate Days'[CALENDAR_DATE] ) - 1
VAR _month =
    MONTH ( _pre_day )
VAR _result =
    CALCULATE (
        COUNT ( 'RunRate Days'[COUNT] ),
        FILTER (
            ALL('RunRate Days'),
            'RunRate Days'[CALENDAR_DATE] <= _pre_day
        )
    ) + 0
RETURN
    _result

 

vcgaomsft_0-1660207711031.png

The PBIX file is attached for reference:

Pbix file

 

Best Regards,
changqing

amitchandak
Super User
Super User

@Anonymous , Try measure like

MTD Yesterday =
var _max = today() -1
var _min = eomonth(_max,-1)+1
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

YTD Yesterday =
var _min = eomonth(today(),-1*month(today()))+1
var _max = today() -1
return
CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

refer more measure here

https://medium.com/chandakamit/cheat-sheet-power-bi-time-intelligence-formulas-using-today-654f26e27304

Anonymous
Not applicable

Thank you @changqing for providing the solution, When plotting a table it's giving me the numbers I am looking for .However, When I put these measures in the visualization , I am getting different output 

 

What I am looking for is for eg:In the month of August

 

1.TOTAL_NBR_SELLING_DAYS are 22

2.Until yesterday NBR_SELLING_DAYS should come to 10

3.YTD_TOTAL_NBR_SELLING_DAYS are 168, rolling sum at the end of August is 168

4.YTD_NBR_SELLING_DAYS   should come to 156, rolling sum untill 16th August is 156

 

Current Result 

Xcape18_0-1660667525375.png

 

However, I am expecting the below numbers.

 

Result Expected

Xcape18_1-1660667581937.png

Please note I don't want to use day slicer.

 

@amitchandak  Thank you too for sharing the DAX , however, It's throwing an error as it's not recognizing [Net] function.

 

 

 

Hi @Anonymous ,

 

Please try:

Until Yesterday NBR_SELLING_DAYS = 
VAR _day =
    TODAY() - 2
VAR _month =
    MONTH ( _day )
VAR _result =
    CALCULATE (
        COUNT ( 'RunRate Days'[COUNT] ),
        FILTER (
            ALL('RunRate Days'),
            'RunRate Days'[CALENDAR_DATE] <= _day
                && 'RunRate Days'[MONTH_COUNT] = _month
        )
    )
RETURN
    _result
YTD number of selling days = 
VAR _day =
    TODAY() - 2
VAR _month =
    MONTH ( _day )
VAR _result =
    CALCULATE (
        COUNT ( 'RunRate Days'[COUNT] ),
        FILTER (
            ALL('RunRate Days'),
            'RunRate Days'[CALENDAR_DATE] <= _day
        )
    )
RETURN
    _result

vcgaomsft_0-1660903685207.png

The PBIX file is attached for reference.

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly -- How to provide sample data

Anonymous
Not applicable

This is Awesome, thank you so much , I just did a minor tweak, instead of T-2 , I used T-1.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.