Forum Discussion
How to create calculate spells ?
- 7 years ago
Hi Taznalem,
Please check out the demo in the attachment. The main steps are as follows.
1. Create an index that can identify the continuous days.
2. Create a measure.
Measure = MAXX ( SUMMARIZE ( 'Table1', 'Table1'[Index], "non-stop", COUNT ( 'Table1'[Training] ) ), [non-stop] )Best Regards,
Dale
Hi Taznalem,
Please try to change the "Added custom" step and the measure.
if [Index] = 0 then 1 else if #"Changed Type"{[Index] - 1}[Date] + #duration(1, 0, 0, 0) = [Date] or
#"Changed Type"{[Index] - 1}[Date] = [Date] then 1 else 0
Measure =
MAXX (
SUMMARIZE (
'Table1',
'Table1'[Index],
"non-stop", DISTINCTCOUNT ( 'Table1'[Date] )
),
[non-stop]
)
Best Regards,
Dale
I appreciate you commentary, but that is not a suitable solution, that is because:
1. When I create the Added custom with the formula:
if [Index] = 0 then
1
else if #"Changed Type"{[Index] - 1}[Date] + #duration(1, 0, 0, 0) = [Date] or #"Changed Type"{[Index] - 1}[Date] = [Date] then
1
else
0
This create a column where is "1" when the date is the same date that the previous one or when it is a continous day:
Date Custom
| 19/09/2018 | 1 |
| 19/09/2018 | 1 |
| 19/09/2018 | 1 |
| 19/09/2018 | 1 |
| 19/09/2018 | 1 |
| 19/09/2018 | 1 |
| 20/09/2018 | 1 |
| 20/09/2018 | 1 |
| 20/09/2018 | 1 |
| 25/09/2018 | 0 |
| 25/09/2018 | 1 |
| 25/09/2018 | 1 |
| 25/09/2018 | 1 |
| 25/09/2018 | 1 |
| 26/09/2018 | 1 |
| 26/09/2018 | 1 |
| 26/09/2018 | 1 |
| 27/09/2018 | 1 |
| 27/09/2018 | 1 |
| 27/09/2018 | 1 |
| 28/09/2018 | 1 |
| 28/09/2018 | 1 |
| 28/09/2018 | 1 |
| 01/10/2018 | 0 |
| 01/10/2018 | 1 |
| 01/10/2018 | 1 |
| 03/10/2018 | 0 |
| 03/10/2018 | 1 |
| 03/10/2018 | 1 |
| 04/10/2018 | 1 |
| 04/10/2018 | 1 |
| 06/10/2018 | 0 |
| 08/10/2018 | 0 |
| 08/10/2018 | 1 |
| 09/10/2018 | 1 |
| 09/10/2018 | 1 |
| 13/10/2018 | 0 |
| 13/10/2018 | 1 |
| 20/10/2018 | 0 |
| 20/10/2018 | 1 |
| 20/10/2018 | 1 |
| 21/10/2018 | 1 |
| 21/10/2018 | 1 |
| 22/10/2018 | 1 |
| 22/10/2018 | 1 |
2. Therefore, when I create the measure is always "1"
Thanks in advance
Alvaro
- v-jiascu-msft7 years agoMicrosoft Employee
Hi Alvaro,
Did you check the demo in the attachment? Your input here is just one step of the solution.
Best Regards,
Dale- Taznalem7 years agoFrequent Visitor
I am sorry, you are right. I have forgotten send you the other column with the formula (I've renamed this column as "FinalIndex")
List.Accumulate(let currentIndex = [Index] in Table.SelectRows(#"Added Custom", each [Index] <= currentIndex)[Custom], 1, (state, val) => if val = 1 then state else state + 1)
Fecha FinalIndex
19/09/2018 1 19/09/2018 1 19/09/2018 1 19/09/2018 1 19/09/2018 1 19/09/2018 1 20/09/2018 2 20/09/2018 2 20/09/2018 2 25/09/2018 3 25/09/2018 3 25/09/2018 3 25/09/2018 3 25/09/2018 3 26/09/2018 4 26/09/2018 4 26/09/2018 4 27/09/2018 5 27/09/2018 5 27/09/2018 5 28/09/2018 6 28/09/2018 6 28/09/2018 6 01/10/2018 7 01/10/2018 7 01/10/2018 7 03/10/2018 8 03/10/2018 8 03/10/2018 8 04/10/2018 9 04/10/2018 9 06/10/2018 10 08/10/2018 11 08/10/2018 11 09/10/2018 12 09/10/2018 12 13/10/2018 13 13/10/2018 13 20/10/2018 14 20/10/2018 14 20/10/2018 14 21/10/2018 15 21/10/2018 15 22/10/2018 16 22/10/2018 16 I think that there is any kind of mistake in the measure because the number is still "1".
Thank you in advance
Alvaro
- v-jiascu-msft7 years agoMicrosoft Employee
Hi Alvaro,
Which measure did you use? Since I have uploaded a demo, can you point out the issue in the demo? You already have a column [FinalIndex]. No issues are on my side. So I can't find out what the issue is on your side. Can you share your file?
Best Regards,
Dale