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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculate the total holidays and businessdays based on location

Hi,

I have a very common scenario which works well in excel but gets tricky while trying to convert in Power BI.

I want to calculate the total holidays between two dates, the trick here is the holidays has to be calculated based on location, I have the screenshot of my holiday_location table and my Employee Fact table, I am unable to create relationship between these two and neither calculate the Holidays including the Weekends, Kinly help me with it.

 

Location_Holiday Table

Country_Name+StatenameState_NameCountry_NameHoliDate
UK and WALES_London, UKLondon, UKUK and WALES29-May-17
UK and WALES_London, UKLondon, UKUK and WALES2-Apr-18
UK and WALES_London, UKLondon, UKUK and WALES25-Dec-17
UK and WALES_London, UKLondon, UKUK and WALES26-Dec-17
UK and WALES_London, UKLondon, UKUK and WALES1-May-17
UK and WALES_London, UKLondon, UKUK and WALES28-May-18
USA_New JerseyNew JerseyUSA1-Jan-18
USA_New JerseyNew JerseyUSA20-Feb-17
USA_New JerseyNew JerseyUSA14-Apr-17
USA_New JerseyNew JerseyUSA29-May-17
USA_New JerseyNew JerseyUSA4-Jul-17
USA_New JerseyNew JerseyUSA4-Sep-17
USA_New JerseyNew JerseyUSA23-Nov-17

 

Fact Table

 

Image.JPG

2 REPLIES 2
v-danhe-msft
Employee
Employee

Hi @Anonymous,

Based on my test, you can refer to below steps:

1.I have entered some sample data to test for your problem like the picture below:

A.PNG

2.Create a new measure and create a Table visual and add the related columns.

Amount of holiday = CALCULATE(COUNTROWS('Location_Holiday Table'),FILTER('Location_Holiday Table',MAX('Fact Table'[Enddate])>'Location_Holiday Table'[HoliDate]+365&&MIN('Fact Table'[Startdate])<'Location_Holiday Table'[HoliDate]+365&&'Location_Holiday Table'[State_Name]=MAX('Fact Table'[Location City])))

C.PNG

Now you can see the result.

 

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/ypobpg6dniy93wy/Calculate%20the%20total%20holidays%20and%20businessdays%20based%20on%20location.pbix?dl=0

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Daniel,

Sorry for the late reply and thanks for your effort,  I have tried your solution and it works perfectly for the given holidays, but when I try to increase the number of holiday dates it gives me blank, below is the complete list of holidays for two states.Kindly let me know if you need any inputs

 

StateHolidate
California1-Jan-18
California20-Feb-17
California14-Apr-17
California29-May-17
California4-Jul-17
California4-Sep-17
California23-Nov-17
California16-Jan-17
California25-Dec-17
California2-Jan-17
California15-Jan-18
California19-Feb-18
California30-Mar-18
California28-May-18
California4-Jul-18
California3-Sep-18
California22-Nov-18
California23-Nov-18
California24-Nov-17
California25-Dec-18
Colorado1-Jan-18
Colorado20-Feb-17
Colorado14-Apr-17
Colorado29-May-17
Colorado4-Jul-17
Colorado4-Sep-17
Colorado23-Nov-17
Colorado16-Jan-17
Colorado25-Dec-17
Colorado2-Jan-17
Colorado15-Jan-18
Colorado19-Feb-18
Colorado30-Mar-18
Colorado28-May-18
Colorado4-Jul-18
Colorado3-Sep-18
Colorado22-Nov-18
Colorado23-Nov-18
Colorado24-Nov-17
Colorado25-Dec-18

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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