cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to find last four business days in a month using DAX Query?

I have a ITEM table which has Item_date column, I want to count all days except last 4 business days of month using DAX. (Also, I have DateDimension table which has following columns:

 Capture.JPG)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: How to find last four business days in a month using DAX Query?

Hi sjain17,

 

Create a measure like pattern below:

Measure =
CALCULATE (
COUNT ( DateDimension[Date] ),
FILTER (
DateDimension,
DateDimension[IsHoliday]
<> 1 & DateDimension[Isweekend]
<> 1
)
)

If you have other contion in your item table,like this:

Measure =
CALCULATE (
    COUNT ( ItemTable[Item] ),
    FILTER (
        DateDimension,
        DateDimension[IsHoliday]
            <> 1 & DateDimension[Isweekend]
            <> 1 & OtherConditions
    )
)

Capture.PNG 

 

Regards,

Jimmy Tao

4 REPLIES 4
Super User
Super User

Re: How to find last four business days in a month using DAX Query?

Tough to say exactly without sample source data to test with. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

But, something along the lines of:

 

VAR __LastDayofMonth = DAY(EOMONTH([Item_date],0)) //this will give you the last day of the month

VAR __LastDaytoCalculate = __LastDayofMonth - 4 //last day you want a calculation for

Not sure exactly what you are going for or trying to calculate so hard to be specific. Are you trying to count days by month, by year? You just want the count?


I have book! Learn Power BI from Packt


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

Proud to be a Datanaut!

Community Support Team
Community Support Team

Re: How to find last four business days in a month using DAX Query?

Hi sjain17,

 

Excluding the business day is not like excluding last 4 days in a month, I would recommend you to create a column which mask workday and other days(weekends or holiday) based on your company schedule, then you can filter all the workday records and use a RANKX() function to rank all workdays, after that you can use measure like pattern like below to filter out all the workdays which can meet your requirement.

calculate(..., filter(table,table[RANK] > 4)) 

Regards,

Jimmy Tao

Anonymous
Not applicable

Re: How to find last four business days in a month using DAX Query?

Thanks for your reply Jimmy. I appreciate your help.

Can you please let me know DAX to mask weekend and list of holiday from date column. Because without aggregate function I am not able to do that. Also, I am using direct query.

My DateDimension Table is as below. I have another table which has Item_date column, I will create a join between Date column to Item_date.

Capture.JPG

Highlighted
Community Support Team
Community Support Team

Re: How to find last four business days in a month using DAX Query?

Hi sjain17,

 

Create a measure like pattern below:

Measure =
CALCULATE (
COUNT ( DateDimension[Date] ),
FILTER (
DateDimension,
DateDimension[IsHoliday]
<> 1 & DateDimension[Isweekend]
<> 1
)
)

If you have other contion in your item table,like this:

Measure =
CALCULATE (
    COUNT ( ItemTable[Item] ),
    FILTER (
        DateDimension,
        DateDimension[IsHoliday]
            <> 1 & DateDimension[Isweekend]
            <> 1 & OtherConditions
    )
)

Capture.PNG 

 

Regards,

Jimmy Tao

Helpful resources

Announcements
Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 294 members 3,579 guests
Please welcome our newest community members: