Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Student | Subject Code | Date | Register Mark |
1001 | MATH22 | 22/09/2022 | Sick |
1001 | GEO22 | 22/09/2022 | Sick |
1001 | PHY22 | 22/09/2022 | Sick |
1001 | MATH22 | 21/09/2022 | Present |
1001 | GEO22 | 21/09/2022 | Present |
1001 | PHY22 | 21/09/2022 | Present |
1001 | MATH22 | 18/09/2022 | Sick |
1001 | GEO22 | 18/09/2022 | Present |
1001 | PHY22 | 18/09/2022 | Present |
1001 | MATH22 | 16/09/2022 | Present |
1001 | GEO22 | 16/09/2022 | Present |
1001 | PHY22 | 16/09/2022 | Present |
1002 | MATH22 | 22/09/2022 | Present |
1002 | GEO22 | 22/09/2022 | Present |
1002 | PHY22 | 22/09/2022 | Present |
1002 | MATH22 | 21/09/2022 | Present |
1002 | GEO22 | 21/09/2022 | Present |
1002 | PHY22 | 21/09/2022 | Present |
1002 | MATH22 | 18/09/2022 | Present |
1002 | GEO22 | 18/09/2022 | Present |
1002 | PHY22 | 18/09/2022 | Present |
1002 | MATH22 | 16/09/2022 | Sick |
1002 | GEO22 | 16/09/2022 | Present |
1002 | PHY22 | 16/09/2022 | Present |
Student | Total Sick days | Current Sickness Streak |
1001 | 2 | 1 |
1002 | 1 | 0 |
Hi @dejate ,
I created a sample pbix file(see attachment) for you, please check whether that is what you want.
1. Create a measure as below to get Total Sick days:
Total Sick days =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Date] ),
FILTER ( 'Table', 'Table'[Register Mark] = "Sick" )
)
2. Follow the steps below to get Current Sickness Streak
1) Create a calculated column as below to judge if the sickness is steak on one whole day
Flag =
VAR _ccount =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Subject Code] ),
FILTER (
'Table',
'Table'[Student] = EARLIER ( 'Table'[Student] )
&& 'Table'[Date] = EARLIER ( 'Table'[Date] )
)
)
VAR _sickcount =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Subject Code] ),
FILTER (
'Table',
'Table'[Student] = EARLIER ( 'Table'[Student] )
&& 'Table'[Date] = EARLIER ( 'Table'[Date] )
&& 'Table'[Register Mark] = "Sick"
)
)
RETURN
IF ( _ccount = _sickcount, 1, 0 )
2) Create a measure as below to get Current Sickness Streak
Current Sickness Streak =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Date] ),
FILTER ( 'Table', 'Table'[Flag] = 1 )
) + 0
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Thnaks for your reply @Anonymous - Your measure for Total Sick days worked great, thnaks for that.
But the consecutive sick day measure just seems to return a 1 Flag for every day in my data. It maybe my grouping, so still trying to work through this, but thanks for your suggestion.
I'm also working through @amitchandak suggestion from https://youtu.be/GdMcwvdwr0o
Thanks both, Ill post my update
Hi @dejate ,
Thanks for your feedback. So do you get the final solution for your problem now? If yes, could you please mark the helpful post as Answered? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.
Best Regards
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
12 | |
11 | |
7 | |
6 |