Forum Discussion
Determine if date is between 2 dates (example 2)
- 8 years ago
I managed to solve my problem with a solution given here:
http://community.powerbi.com/t5/Desktop/Dynamically-generate-table-rows-for-each-row/m-p/101483#M4255
HI Silko
How about adding a Calculated Column in your Main Table stating if the User was PRESENT or ABSENT on that day
Then you can filter only those who were ABSENT
Present or Absent =
VAR Check =
CALCULATE (
COUNTROWS ( AbsenceTable ),
FILTER (
AbsenceTable,
AbsenceTable[User ID] = MainTable[User ID]
&& AbsenceTable[Start Date] <= MainTable[Date]
&& AbsenceTable[End Date] >= MainTable[Date]
)
)
RETURN
IF ( Check >= 1, "Absent", "Present" )I'm not sure you got my question right. I'm talking only about absent users and my absence table looks like this:
start_date | end_date | user_id (absent_user_id)
1.1.2017 3.1.2017 1
3.1.2017 3.1.2017 2
I need it to look like this:
date | absent_user_id
1.1.2017 | 1
2.1.2017 | 1
3.1.2017 | 1
3.1.2017 | 2
...
- Zubair_Muhammad8 years agoCommunity Champion
My apologies. :smileyembarrassed:
I thought you have 2 Tables.
One with Dates and Users.And other one ... the absence Table
So you want to TRANsform your Absence table into that FORMAT... Right?
- Silko8 years agoHelper II
Zubair_Muhammad yes that's correct.
- Zubair_Muhammad8 years agoCommunity Champion
Hi Silko
Good to see this Power Query Solution
Here is a DAX solution
Go to Modelling Tab>>>New Table
NEW TABLE = GENERATE ( ALL ( AbsenceTable[User ID] ), GENERATESERIES ( CALCULATETABLE ( VALUES ( AbsenceTable[Start Date] ) ), CALCULATETABLE ( VALUES ( AbsenceTable[End Date] ) ) ) )