Forum Discussion
Problem grouping by days
- Anonymous4 years ago
Hi Anonymous ,
I suggest you to add a date only column in your data table. It will help us to group the table in calculation.
Datevalue = DATEVALUE('Table'[Time])Try this code.
Measure = VAR _T = SUMMARIZE(ALL('Table'),'Table'[Datevalue],"Count",CALCULATE(DISTINCTCOUNT('Table'[Value]),ALLEXCEPT('Table','Table'[Datevalue])),"Max",CALCULATE(MAX('Table'[Value]),ALLEXCEPT('Table','Table'[Datevalue]))) RETURN COUNTAX(FILTER(_T,[Datevalue]<=MAX('Table'[Datevalue])&&[Count] = 1&&[Max] = 0),[Datevalue]) +0Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is a more complete data. Basically I have a lot of locations and I would like to see how many consecutive days do I have with 0 data for a whole day in all locations
| Time | Location | Value |
| 01/01/2022 00:00 | 1 | 0.455741 |
| 01/01/2022 06:00 | 1 | 0 |
| 01/01/2022 12:00 | 1 | 0 |
| 01/01/2022 18:00 | 1 | 1 |
| 02/01/2022 00:00 | 1 | 0 |
| 02/01/2022 06:00 | 1 | 0 |
| 02/01/2022 12:00 | 1 | 0 |
| 02/01/2022 18:00 | 1 | 0 |
| 03/01/2022 00:00 | 1 | 0 |
| 03/01/2022 06:00 | 1 | 0 |
| 03/01/2022 12:00 | 1 | 0 |
| 03/01/2022 18:00 | 1 | 0 |
| 01/01/2022 00:00 | 2 | 0.433114 |
| 01/01/2022 06:00 | 2 | 0.778561 |
| 01/01/2022 12:00 | 2 | 0.961754 |
| 01/01/2022 18:00 | 2 | 0.878894 |
| 02/01/2022 00:00 | 2 | 0 |
| 02/01/2022 06:00 | 2 | 0 |
| 02/01/2022 12:00 | 2 | 0 |
| 02/01/2022 18:00 | 2 | 0 |
| 03/01/2022 00:00 | 2 | 0 |
| 03/01/2022 06:00 | 2 | 0 |
| 03/01/2022 12:00 | 2 | 0 |
| 03/01/2022 18:00 | 2 | 0 |
The output I am loo king for is a measure with the consecutive 0 values as below:
| Date | Measure |
| 01/01/2022 | 0 |
| 02/01/2022 | 1 |
| 03/01/2022 | 2 |
Hi Anonymous ,
I suggest you to add a date only column in your data table. It will help us to group the table in calculation.
Datevalue = DATEVALUE('Table'[Time])
Try this code.
Measure =
VAR _T =
SUMMARIZE(ALL('Table'),'Table'[Datevalue],"Count",CALCULATE(DISTINCTCOUNT('Table'[Value]),ALLEXCEPT('Table','Table'[Datevalue])),"Max",CALCULATE(MAX('Table'[Value]),ALLEXCEPT('Table','Table'[Datevalue])))
RETURN
COUNTAX(FILTER(_T,[Datevalue]<=MAX('Table'[Datevalue])&&[Count] = 1&&[Max] = 0),[Datevalue]) +0
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.