PowerBI : How to Calculate number of WorkingDays between 2 given dates

Here i am going to explain how to calculate number of working dates between to given dates.
In my approach i am taking a table called Holidays which contains holidays as shown below

Once you have this table , we need to use this table in our Datetime table to calculate IsworkingDay column.

Now give the relationship between Datetime and Holidays tables as shown below



DAX :  IsWorkingDay = IF (NOT(DateTime[Day of Week]= "Saturday" || (DateTime[Day of Week]= "Sunday")) && COUNTX(RELATEDTABLE(Holidays),2)<1,1,0)

Now you can create calculated column or measure 


Total Working Days Column = 
SUMX (
    FILTER (
        'Datetime',
        'Datetime'[Date] >= Tasks[Input Start Date]
            && 'Datetime'[Date] <= Tasks[Input End Date]
    ),
    'Datetime'[IsWorkingDay]
)


Total Working Days Measure = 
SUMX (
    FILTER (
        'Datetime',
        'Datetime'[Date] >= MIN ( Tasks[INput Start Date] )
            && 'Datetime'[Date] <= MAX ( Tasks[Input End Date] )
    ),
    'Datetime'[IsWorkingDay]
)



Comments

  1. Thank you so much for making understand the use of Power BI through mathematical and logical problems and finding out solutions.

    Powerbi Read Soap

    ReplyDelete

Post a Comment

Popular posts from this blog

SSAS : A connection cannot be made to redirector. Ensure that 'SQL Browser' service is running. (Microsoft.AnalysisServices.AdomdClient). + Solution

SSIS Error : Unable to infer the XSD from the XML file. The XML contains multiple namespaces