March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
hi PBI community members:
i have a data table with a employee ID, the startdate and the end date of a sickness case. i want to present the number of working days in a graph, and i want to classify the number of working days in 3 categories. The way of the classification is depending on wether or not the sickness end date is in or later than the selected period:
For example:
Employee ID | Start date | End date |
23 | 03-04-2020 | 05-04-2020 |
27 | 04-04-2020 | 03-07-2020 |
30 | 03-03-2020 | 10-08-2020 |
35 | 01-01-2020 | 05-01-2020 |
40 | 05-02-2020 | 10-02-2020 |
I want the following table or graph:
Class: | Q1 2020 | Q1 2020 | Q3 2020 |
0-5 working days | 7 | 1 | 0 |
6-30 working days | 21 | 0 | 0 |
30-999 working days | 0 | 127 | 32 |
I need the number of working days between start date and end date, but if the end date is later than the end date of the selected period (in this case quaterly), than i need the number of working days between start date and last date of the quarter. So the sickness case of employee 30 (start date 03-03-2020) is classified in Q1 as "5-30 working days", but in Q2 it is classified as "30-999 working days".
Does anyone have a solution for this?
Thanks in advance,
Regards,
Frank
Solved! Go to Solution.
Hi, @frankhofmans
According to your description and sample data, I get the expected result through calculated column and matrix, you can take a look at my method and find if it’s useful:
Q1 2020 =
var _endofquater=DATE(2020,3,31)
var _datediff=DATEDIFF('Table'[Start date],_endofquater,DAY)
var _compare=DATEDIFF('Table'[End date],_endofquater,DAY)
var _value= IF(_compare<0,ABS(_datediff),BLANK())
return
SWITCH(TRUE(),
_value>0&&_value<=5,"0-5 working days",
_value>6&&_value<=30,"6-30 working days",
_value>30&&_value<=999,"30-999 working days",
"Ineligible")
Q2 2020 =
var _endofquater=DATE(2020,6,30)
var _datediff=DATEDIFF('Table'[Start date],_endofquater,DAY)
var _compare=DATEDIFF('Table'[End date],_endofquater,DAY)
var _value= IF(_compare<0,ABS(_datediff),BLANK())
return
SWITCH(TRUE(),
_value>0&&_value<=5,"0-5 working days",
_value>6&&_value<=30,"6-30 working days",
_value>30&&_value<=999,"30-999 working days",
"Ineligible")
Q3 2020 =
var _endofquater=DATE(2020,9,30)
var _datediff=DATEDIFF('Table'[Start date],_endofquater,DAY)
var _compare=DATEDIFF('Table'[End date],_endofquater,DAY)
var _value= IF(_compare<0,ABS(_datediff),BLANK())
return
SWITCH(TRUE(),
_value>0&&_value<=5,"0-5 working days",
_value>6&&_value<=30,"6-30 working days",
_value>30&&_value<=999,"30-999 working days",
"Ineligible")
And I guess this is what you want.
You can download my test pbix file here
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @frankhofmans
According to your description and sample data, I get the expected result through calculated column and matrix, you can take a look at my method and find if it’s useful:
Q1 2020 =
var _endofquater=DATE(2020,3,31)
var _datediff=DATEDIFF('Table'[Start date],_endofquater,DAY)
var _compare=DATEDIFF('Table'[End date],_endofquater,DAY)
var _value= IF(_compare<0,ABS(_datediff),BLANK())
return
SWITCH(TRUE(),
_value>0&&_value<=5,"0-5 working days",
_value>6&&_value<=30,"6-30 working days",
_value>30&&_value<=999,"30-999 working days",
"Ineligible")
Q2 2020 =
var _endofquater=DATE(2020,6,30)
var _datediff=DATEDIFF('Table'[Start date],_endofquater,DAY)
var _compare=DATEDIFF('Table'[End date],_endofquater,DAY)
var _value= IF(_compare<0,ABS(_datediff),BLANK())
return
SWITCH(TRUE(),
_value>0&&_value<=5,"0-5 working days",
_value>6&&_value<=30,"6-30 working days",
_value>30&&_value<=999,"30-999 working days",
"Ineligible")
Q3 2020 =
var _endofquater=DATE(2020,9,30)
var _datediff=DATEDIFF('Table'[Start date],_endofquater,DAY)
var _compare=DATEDIFF('Table'[End date],_endofquater,DAY)
var _value= IF(_compare<0,ABS(_datediff),BLANK())
return
SWITCH(TRUE(),
_value>0&&_value<=5,"0-5 working days",
_value>6&&_value<=30,"6-30 working days",
_value>30&&_value<=999,"30-999 working days",
"Ineligible")
And I guess this is what you want.
You can download my test pbix file here
Best Regards,
Community Support Team _Robert Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@frankhofmans , 2 Steps, First you need create a measure for working day diff and then you need to do dynamic segmentation
Refer this file : https://www.dropbox.com/s/o2v5ekfiw5057do/Working%20date%20between%20Dates%20Measure%20and%20Table.p...
or
https://www.sqlbi.com/articles/counting-working-days-in-dax/
Dynamic segmentation: https://youtu.be/CuczXPj0N-k
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
87 | |
87 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |