Forum Discussion

adarshmp8998's avatar
adarshmp8998
Frequent Visitor
2 years ago
Solved

Alarm Log, Start Time & End Time in Power BI Visual

Hi Team,

 

I am tring to create a Alarm Log in Power BI Desktop. where I have asset wise alarms. Start and End time is available in the same date time column. State 1 or 2 or 3 means alarm is clear and if rest alarm category is available in alarm category column. 

 

Note: I can have same alarm for same device multiple time and each alarm should be come in Alarm Log

 

Visual should be like below table.

Date TimeAsset NameAlarm CategoryStart TimeEnd Time
29-02-2024 15:11XAlarm A29-02-2024 15:1129-02-2024 15:11
29-02-2024 15:12XAlarm A29-02-2024 15:1229-02-2024 15:12
29-02-2024 15:15XAlarm A29-02-2024 15:1529-02-2024 15:15
29-02-2024 15:16YAlarm B29-02-2024 15:1629-02-2024 15:16
29-02-2024 15:17YAlarm B29-02-2024 15:1729-02-2024 15:17
29-02-2024 15:19YAlarm B29-02-2024 15:1929-02-2024 15:19
29-02-2024 15:20YAlarm B29-02-2024 15:2029-02-2024 15:20

 

Can anyone help me to find the same?

 

Thank You in adavance..

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, adarshmp8998 

    You can create a new table. the following is the dax:

    Alarm Log = 
    ADDCOLUMNS(
        FILTER(
            'Table',
            'Table'[State Number] <> 1 && 
            'Table'[State Number] <> 2 && 
            'Table'[State Number] <> 3
        ),
        "Start Time", 'Table'[Date Time],
        "End Time", 
        CALCULATE(
            MIN('Table'[Date Time]),
            FILTER(
                ALL('Table'),
                'Table'[Asset] = EARLIER('Table'[Asset]) && 
                'Table'[Date Time] > EARLIER('Table'[Date Time]) && 
                ('Table'[State Number] = 1 || 
                'Table'[State Number] = 2 || 
                'Table'[State Number] = 3)
            )
        )
    )
    

    Here is my preview:

     

    How to Get Your Question Answered Quickly 

    Best Regards

    Yongkang Hua

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

5 Replies

  • adarshmp8998's avatar
    adarshmp8998
    Frequent Visitor
    Date TimeAsset NameAlarm CategoryStart TimeEnd Time
    29-02-2024 15:11XAlarm A29-02-2024 15:1129-02-2024 15:11
    29-02-2024 15:12XAlarm A29-02-2024 15:1229-02-2024 15:12
    29-02-2024 15:15XAlarm A29-02-2024 15:1529-02-2024 15:15
    29-02-2024 15:16YAlarm B29-02-2024 15:1629-02-2024 15:16
    29-02-2024 15:17YAlarm B29-02-2024 15:1729-02-2024 15:17
    29-02-2024 15:19YAlarm B29-02-2024 15:1929-02-2024 15:19
    29-02-2024 15:20YAlarm B29-02-2024 15:2029-02-2024 15:20

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, adarshmp8998 

    It seems that you have only provided your expected data, can you provide you with sample data or PBIX files that do not contain private information?

     

    Best Regards

    Yongkang Hua

    • adarshmp8998's avatar
      adarshmp8998
      Frequent Visitor

      Hi Anonymous ,

       

      Thank You for replying. Sharing a sample dataset with you.

       

      Date TimeAssetState NumberAlarm Category
      09-02-2024 10:57A2Clear
      09-02-2024 11:29A101Low Temp
      09-02-2024 11:30A101Low Temp
      09-02-2024 11:31A101Low Temp
      09-02-2024 11:32A101Low Temp
      09-02-2024 11:34A101Low Temp
      09-02-2024 11:35A101Low Temp
      09-02-2024 11:36A2Clear
      09-02-2024 11:37A2Clear
      09-02-2024 11:38A2Clear
      09-02-2024 11:39A2Clear
      09-02-2024 11:40A101Low Temp
      09-02-2024 11:41A101Low Temp
      09-02-2024 11:42A101Low Temp
      09-02-2024 11:43A101Low Temp
      09-02-2024 11:44A101Low Temp
      09-02-2024 11:45A101Low Temp
      09-02-2024 11:46A101Low Temp
      09-02-2024 11:47A2Clear
      09-02-2024 11:48A2Clear
      09-02-2024 11:49A2Clear
      09-02-2024 11:50A1Clear
      09-02-2024 11:51A1Clear
      09-02-2024 11:53A1Clear
      09-02-2024 11:55A1Clear
      09-02-2024 10:57B2Clear
      09-02-2024 11:29B101Low Temp
      09-02-2024 11:30B101Low Temp
      09-02-2024 11:31B101Low Temp
      09-02-2024 11:32B101Low Temp
      09-02-2024 11:34B101Low Temp
      09-02-2024 11:35B101Low Temp
      09-02-2024 11:36B2Clear
      09-02-2024 11:37B2Clear
      09-02-2024 11:38B2Clear
      09-02-2024 11:39B2Clear
      09-02-2024 11:40B101Low Temp
      09-02-2024 11:41B101Low Temp
      09-02-2024 11:42B101Low Temp
      09-02-2024 11:43B101Low Temp
      09-02-2024 11:44B101Low Temp
      09-02-2024 11:45B101Low Temp
      09-02-2024 11:46B101Low Temp
      09-02-2024 11:47B2Clear
      09-02-2024 11:48B2Clear
      09-02-2024 11:49B2Clear
      09-02-2024 11:50B1Clear
      09-02-2024 11:51B1Clear
      09-02-2024 11:53B1Clear
      09-02-2024 11:55B1Clear
      09-02-2024 10:57C2Clear
      09-02-2024 11:29C101Low Temp
      09-02-2024 11:30C101Low Temp
      09-02-2024 11:31C101Low Temp
      09-02-2024 11:32C101Low Temp
      09-02-2024 11:34C101Low Temp
      09-02-2024 11:35C101Low Temp
      09-02-2024 11:36C2Clear
      09-02-2024 11:37C2Clear
      09-02-2024 11:38C2Clear
      09-02-2024 11:39C2Clear
      09-02-2024 11:40C101Low Temp
      09-02-2024 11:41C101Low Temp
      09-02-2024 11:42C101Low Temp
      09-02-2024 11:43C101Low Temp
      09-02-2024 11:44C101Low Temp
      09-02-2024 11:45C101Low Temp
      09-02-2024 11:46C101Low Temp
      09-02-2024 11:47C2Clear
      09-02-2024 11:48C2Clear
      09-02-2024 11:49C2Clear
      09-02-2024 11:50C1Clear
      09-02-2024 11:51C1Clear
      09-02-2024 11:53C1Clear
      09-02-2024 11:55C1Clear
      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi, adarshmp8998 

        You can create a new table. the following is the dax:

        Alarm Log = 
        ADDCOLUMNS(
            FILTER(
                'Table',
                'Table'[State Number] <> 1 && 
                'Table'[State Number] <> 2 && 
                'Table'[State Number] <> 3
            ),
            "Start Time", 'Table'[Date Time],
            "End Time", 
            CALCULATE(
                MIN('Table'[Date Time]),
                FILTER(
                    ALL('Table'),
                    'Table'[Asset] = EARLIER('Table'[Asset]) && 
                    'Table'[Date Time] > EARLIER('Table'[Date Time]) && 
                    ('Table'[State Number] = 1 || 
                    'Table'[State Number] = 2 || 
                    'Table'[State Number] = 3)
                )
            )
        )
        

        Here is my preview:

         

        How to Get Your Question Answered Quickly 

        Best Regards

        Yongkang Hua

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