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
ThomasWeppler
Skilled Sharer
Skilled Sharer

Multiple date filters in same table

I need a table which shows the % sick leave for employess over 12 and 3 months, so the two numbers easily can be compared.

For the 12 months I just added a relative date for the last 12 months. 

ThomasWeppler_0-1616597094049.png

To add the three months filter I wrote it in Dax and added the same calculation, but with a dateinperiode filter. 

Here is the Dax

 

Fraværsprocent 3 =
DIVIDE(
CALCULATE (
COUNTROWS ( 'workplanentry' ),
'workplanentry'[title] = "Sygedag"
|| 'workplanentry'[title] = "Barn 1. sygedag"
|| 'workplanentry'[title] = "langtidssygemeldt"
|| 'workplanentry'[title] = "Coronasyg"
|| 'workplanentry'[title] = "off sick", DATESINPERIOD('workplanentry'[date], TODAY(), -3, MONTH)
),
CALCULATE (
COUNTROWS ( 'workplanentry' ),
'workplanentry'[title] = "Sygedag"
|| 'workplanentry'[title] = "Barn 1. sygedag"
|| 'workplanentry'[title] = "Fraværsdag"
|| 'workplanentry'[title] = "Omsorgsdag"
|| 'workplanentry'[title] = "Arbejdsdag"
|| 'workplanentry'[title] = "Skole/Kursus"
|| 'workplanentry'[title] = "Afspadsering"
|| 'workplanentry'[title] = "langtidssygemeldt"
|| 'workplanentry'[title] = "Coronasyg"
|| 'workplanentry'[title] = "off sick"
|| 'workplanentry'[title] = "dødsfald"
|| 'workplanentry'[title] = "Corona produktionsstop"
|| 'workplanentry'[title] = "Workday", DATESINPERIOD('workplanentry'[date], TODAY(), -3, MONTH))
)

After I wanted to check if it worked as intended, so I changed the first filter to 3 months thinking that the 2 numbers would be the same, since I would apply the same filter to both calculations.
The number was however different.

So here is my question. Can anyone tell me why the dateinperiod and relative date works diffrently. Can I change something in my Dax function to get the same numbers or would it be better to build the calculation in an entirely different ways?

All help is appreciated. 🙂
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ThomasWeppler , relative date filter the dates in table. Means 3 months of data is only available.

 

Say you filter for a date and use dateinperiod for 3 month with date table , Then you will get data rolling for 3 month for that date.

 

If you more than one date selected dateinperiod  will give 3 months for all the dates

 

Also, check this video when wanting to select one date and show a trend https://www.youtube.com/watch?v=duMSovyosXE

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@ThomasWeppler , relative date filter the dates in table. Means 3 months of data is only available.

 

Say you filter for a date and use dateinperiod for 3 month with date table , Then you will get data rolling for 3 month for that date.

 

If you more than one date selected dateinperiod  will give 3 months for all the dates

 

Also, check this video when wanting to select one date and show a trend https://www.youtube.com/watch?v=duMSovyosXE

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.