Forum Discussion
Recuento de ciclos
- 6 years ago
@JoeJoe666 - Ah, quieres Cthulhu - https://community.powerbi.com/t5/Quick-Measures-Gallery/Cthulhu/m-p/509739#M211
En realidad, no, no Cthulhu pero se puede hacer con 2 columnas, todavía estoy trabajando en la versión de una sola columna. PBIX se adjunta debajo de sig, es tabla (13).
Cycle Change = VAR __Table = FILTER('Table (13)',[device]=EARLIER([device]) && [time]<=EARLIER([Time])) VAR __Previous = MAXX(FILTER(__Table,[time]<EARLIER([Time])),[Time]) VAR __PreviousState = MAXX(FILTER(__Table,[Time]=__Previous),[State]) RETURN IF(([State]=1 && __PreviousState<>1),1,0) Cycles = SUMX(FILTER('Table (13)',[device]=EARLIER([device]) && [Time]<=EARLIER([Time])),[Cycle Change])OK, metí esto en una sola columna:
Single Column non working = VAR __BaseTable = 'Table (13)' VAR __Table = ADDCOLUMNS( ADDCOLUMNS( ADDCOLUMNS( FILTER(__BaseTable,[device]=EARLIER([device]) && [time]<=EARLIER([Time])), "__Previous",MAXX(FILTER(__BaseTable,[time]<EARLIER([Time])),[Time]) ), "__PreviousState",MAXX(FILTER(__BaseTable,[Time]=[__Previous]),[State]) ), "__CycleChange",IF(([State]=1 && [__PreviousState]<>1),1,0) ) RETURN SUMX(__Table,[__CycleChange])Se ha actualizado el PBIX.
probó el enfoque de 2 columnas y la 1a columna ni siquiera regresa. mismo problema de memoria. 1 cosa, mis datos siempre vienen en orden cronológico para la columna de tiempo. ¿Sería menos procesamiento si no se requiere [time]<EARLIER[time]? mi mesa está pre-ordenada por tiempo y dispositivo
@JoeJoe666- Bueno, podría intentar agregar un índice a la tabla en Power Query. Entonces usted podría utilizar esto:
1 columna:
Cycles Count Column 1 =
VAR __Index = [Index]
VAR __device = [device]
VAR __WorkingTable = FILTER('Table',[device]=__device && [Index]<=__Index)
VAR __Table =
ADDCOLUMNS(
ADDCOLUMNS(
ADDCOLUMNS(
__WorkingTable,
"__Previous",MAXX(FILTER(__WorkingTable,[time]<EARLIER([Time])),[Time])
),
"__PreviousState",MAXX(FILTER(__WorkingTable,[Time]=[__Previous]),[State])
),
"__CycleChange",IF(([State]=1 && [__PreviousState]<>1),1,0)
)
RETURN
SUMX(__Table,[__CycleChange])
2 columnas:
Cycle Change Step 1 =
VAR __Table = FILTER('Table',[device]=EARLIER([device]) && [Index]<=EARLIER([Index]))
VAR __Previous = MAXX(FILTER(__Table,[Index]<EARLIER([Index])),[Index])
VAR __PreviousState = MAXX(FILTER(__Table,[Index]=__Previous),[State])
RETURN
IF(([State]=1 && __PreviousState<>1),1,0)
Cycles 2 = SUMX(FILTER('Table',[device]=EARLIER([device]) && [Index]<=EARLIER([Index])),[Cycle Change Step 1])
Estoy trabajando a través de otro método.
- Greg_Deckler6 years ago
Community Champion
@JoeJoe666 - OK, aquí hay otro método para el proceso de 2 pasos que puede funcionar mejor (debe)
Cycle Change Step 1a = VAR __device = [device] VAR __Index = [Index] VAR __Previous = CALCULATE(MAX([Index]),FILTER('Table',[device]=__device && [Index]<__Index)) VAR __PreviousState = CALCULATE(MAX([State]),FILTER('Table',[Index]=__Previous)) RETURN IF(([State]=1 && __PreviousState<>1),1,0) Cycles 2a = VAR __device = [device] VAR __Index = [Index] RETURN CALCULATE(SUM([Cycle Change Step 1a]), FILTER('Table',[device]=__device && [Index]<=__Index))- Greg_Deckler6 years ago
Community Champion
@JoeJoe666 - Sólo haciendo un seguimiento, ¿alguna vez hizo esto operativo?