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
mb769
Frequent Visitor

Number of absences per day of week

I have a table ABSENCE with employee absences in this form:

IDStartDateEndDate
101/09/202230/09/2022
205/09/202206/09/2022

I also have a DATE Table with all dates, which includes the day of the week (Monday to Sunday)

 

I am aiming to make a bar chart which shows me the number of absence-days for each day of the week, i.e. something that looks similar to this:

image.png

First, I wanted to make a measure which counts all Dates included in an Absence. I have been struggling with codes like this, but it doesn't give me the correct results, since it does not filter on weekday.

 

CALCULATE (
    COUNTROWS(Date),
        DATESBETWEEN (
        Date[Date],
        Min(ABSENCE[StartDate]),
        Min(ABSENCE[EndDate])
    )
)
This gives me the following result:
image.png

Somehow I am missing the clue, but I cannot figure out how and where.

 

Has anyone encountered a problem like this before?
Many thanks in advance for your help.

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@mb769 
Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@mb769 
Take a look at these two Quick Measures as I think you want something like them.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Perfect!

The GENERATE function did the trick.

johnt75
Super User
Super User

You could create a calculated table with all absence dates in it like

Absence dates =
SELECTCOLUMNS(
	GENERATE(
	'Table',
	DATESBETWEEN('Date'[Date], 'Table'[Start date], 'Table'[End date])
	),
	'Table'[Employee ID],
	[Date]
)

link that to your date table and then you can write a simple COUNTROWS measure to show the number of absences over any time period or sliced by day of week etc

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.