Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JoeJoe666
Frequent Visitor

Recuento de ciclos

Hola

Soy nuevo en power BI. No estoy seguro de si necesito usar DAX o M para lo que necesito.

Me gustaría crear un recuento cíclico en una nueva columna basada en lo siguiente:

*para cada dispositivo

*cambiar el ciclo cuando el estado alcanza "1"

*Cada dispositivo tiene sus propios recuentos de ciclos

*los ciclos aumentan en 1

*los ciclos deben estar en orden cronológico por "tiempo", para cada dispositivo

Intenté lo siguiente sin éxito:

Ciclos: CALCULATE(DISTINCTCOUNT(Sheet2[Estado]),
FILTRO(Sheet2,
Sheet2[Time]<EARLIER(Sheet2[Time]) &&
Sheet2[Estado]<2 &&
Sheet2[dispositivo]-EARLIER(Sheet2[dispositivo])))
Nombre de la tabla: "Sheet2"
HoraDispositivom1m2m3EstadoCiclos
9/1/2020 0:014-0.103010011
9/1/2020 12:564-0.103010011
9/1/2020 13:264-0.103010011
9/1/2020 13:264-0.594010041
9/1/2020 13:314-0.594-0.110041
9/1/2020 13:364-0.654-1599.941
9/1/2020 20:3140.02-24.777.341
9/1/2020 20:33416.927077.831
9/1/2020 20:38417.4071.579.131
9/1/2020 20:58417.3317.384.431
9/1/2020 21:23417.28214.591.131
9/1/2020 21:27417.28415.992.431
9/1/2020 21:28415.92616.292.621
9/1/2020 23:2342.26925.6101.321
9/1/2020 23:4341.86226.4101.921
9/1/2020 23:444-0.1010012
9/2/2020 0:144-0.1010012
9/2/2020 7:194-0.102010012
9/2/2020 7:244-0.102010012
9/2/2020 7:264-0.175010042
9/2/2020 7:314-1.253-0.199.942
9/2/2020 20:014-0.025-579.742
9/2/2020 20:064-0.025-1579.742
9/2/2020 20:114-0.025-22.279.742
9/2/2020 20:1547.011080.132
9/2/2020 20:20417.4481.581.532
9/2/2020 20:35417.3765.985.532
9/2/2020 20:55417.34411.690.832
9/2/2020 20:58416.89712.591.622
9/2/2020 21:1849.27215.694.422
9/2/2020 23:0842.27422.6100.822
9/2/2020 23:1141.002010013
9/3/2020 9:354-0.102010013
9/3/2020 9:394-1.319010043
9/3/2020 9:494-0.661-0.199.943
9/3/2020 14:094-3.817-15.485.943
9/3/2020 20:344-0.294-33.269.643
9/3/2020 20:36417.005070.133
9/3/2020 21:21417.30513.18233
9/3/2020 21:56417.39823.291.333
9/3/2020 21:57415.34723.491.523
9/3/2020 22:5744.32230.898.323
9/4/2020 0:3242.24834.9102.123
9/4/2020 0:3440.622010014
9/4/2020 7:144-0.103010014
9/4/2020 7:184-0.716010044
9/4/2020 7:234-1.818-0.299.944
9/4/2020 12:234-7.451-793.644
9/4/2020 13:584-3.936-14.986.344
9/4/2020 18:484-0.704-26.975.344
9/4/2020 18:51411.033075.834
9/4/2020 19:16417.2687.382.534
9/4/2020 19:46417.22315.990.434
9/4/2020 19:51416.99417.291.624
9/4/2020 22:1142.24927.9101.424
9/4/2020 22:124-0.102010015
9/4/2020 23:524-0.104010015
9/1/2020 0:017-0.103010011
9/1/2020 12:567-0.103010011
9/1/2020 13:267-0.103010011
9/1/2020 13:267-0.594010041
9/1/2020 13:317-0.594-0.110041
9/1/2020 13:367-0.654-1599.941
9/1/2020 20:3170.02-24.777.341
9/1/2020 20:33716.927077.831
9/1/2020 20:38717.4071.579.131
9/1/2020 20:58717.3317.384.431
9/1/2020 21:23717.28214.591.131
9/1/2020 21:27717.28415.992.431
9/1/2020 21:28715.92616.292.621
9/1/2020 23:2372.26925.6101.321
9/1/2020 23:4371.86226.4101.921
9/1/2020 23:447-0.1010012
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@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.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

11 REPLIES 11

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.