Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Duda medida Power Bi

Buenas. Estoy intentando hacer una medida que dado el periodo de tiempo seleccionado en el slicer me cuente el numero de programas que estaban en estado  corriendo para el ultimo registro que haya habido de cada programa en ese periodo de tiempo.

He realizado lo siguiente pero no realiza lo que quiero. La parte de decirme en que estado se encontraban en el maximo de ese periodo de tiempo lo hace bien pero la cuenta no la realiza. He puesto los campos en una tabla y veo que el actualstatus me pone un uno si el estado es running pero no hace la suma de cuantos programas estaban en running. Alguien me puede decir en que estoy fallando?

 

ActualStatus =
VAR maxDate =
CALCULATE ( MAX ( Table[DateTime] ), ALLSELECTED ( Table[DateTime] ) )
RETURN
CALCULATE(DISTINCTCOUNT(Table[ProgramName]),Table[DateTime]=maxDate,Table[Status]=="RUNNING")
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    1.My sample data is this.

    DateTime

    ProgramName

    Status

    9/1/2020

    1002

    RUNNING

    9/1/2020

    1003

    RUNNING

    9/1/2020

    1001

    RUNNING

    9/1/2020

    1004

    PAUSED

    9/2/2020

    1001

    RUNNING

    9/2/2020

    1002

    RUNNING

    9/2/2020

    1003

    RUNNING

    9/2/2020

    1004

    RUNNING

    9/3/2020

    1003

    RUNNING

    9/3/2020

    1001

    PAUSED

    9/3/2020

    1002

    RUNNING

    9/3/2020

    1004

    RUNNING

    9/4/2020

    1001

    PAUSED

    9/4/2020

    1002

    RUNNING

    9/4/2020

    1003

    RUNNING

    9/4/2020

    1004

    PAUSED

    9/5/2020

    1001

    PAUSED

    9/5/2020

    1002

    RUNNING

    9/5/2020

    1003

    PAUSED

    9/5/2020

    1004

    RUNNING

    9/6/2020

    1004

    RUNNING

     

    2.Try this measure.

    Count = 
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[ProgramName] ),
            [Status] = "RUNNING"
                && [DateTime] = MAX ( 'Table'[DateTime] )
        )
    )

     

    3.Choose between the types of slicers.

     

    4.The result is this.

     

    You can check more details from here.

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Anonymous's avatar
    Anonymous
    5 years ago

    Lo he provado en mis datos y me sigue dando la cuenta 1 o en blanco.

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    1.My sample data is this.

    DateTime

    ProgramName

    Status

    9/1/2020

    1002

    RUNNING

    9/1/2020

    1003

    RUNNING

    9/1/2020

    1001

    RUNNING

    9/1/2020

    1004

    PAUSED

    9/2/2020

    1001

    RUNNING

    9/2/2020

    1002

    RUNNING

    9/2/2020

    1003

    RUNNING

    9/2/2020

    1004

    RUNNING

    9/3/2020

    1003

    RUNNING

    9/3/2020

    1001

    PAUSED

    9/3/2020

    1002

    RUNNING

    9/3/2020

    1004

    RUNNING

    9/4/2020

    1001

    PAUSED

    9/4/2020

    1002

    RUNNING

    9/4/2020

    1003

    RUNNING

    9/4/2020

    1004

    PAUSED

    9/5/2020

    1001

    PAUSED

    9/5/2020

    1002

    RUNNING

    9/5/2020

    1003

    PAUSED

    9/5/2020

    1004

    RUNNING

    9/6/2020

    1004

    RUNNING

     

    2.Try this measure.

    Count = 
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[ProgramName] ),
            [Status] = "RUNNING"
                && [DateTime] = MAX ( 'Table'[DateTime] )
        )
    )

     

    3.Choose between the types of slicers.

     

    4.The result is this.

     

    You can check more details from here.

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Lo he provado en mis datos y me sigue dando la cuenta 1 o en blanco.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Buenas veo que tu medida realiza la cuenta pero no es tal cual la necesito. Necesito que dado el periodo de tiempo seleccionado cuente los equipos que se encuentran en running en su ultimo estado. Por ejemplo para los datos tuyos el dia 9/6/2020 la cuenta deberia ser 2. Ya que el programa 1004 ese mismo dia estaba en running y el 1002 el dia anterior estaba en running y al no haber mas registros de ese programa entendemos que para el dia 9/6/2020 sigue en running.