Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Multiple group by/ranking issue

I have a faily simple data issue, which seems like it could be complicated in Power BI, but I'm a relative newbie so I'm hoping someone can point me in the right direction.

 

Here's the overview: I have data which includes multiple plants, each plant has multiple wind turbines, and each turbine has multiple alarms which go off on a daily basis. What I need to do is this:

 

1. Count how many alarms went off per plant per day, by alarm type.

2. Find the top n (in this simple case n = 2) alarms, by plant, for any date range the user selects.

3. Once we know which were the top 2 alarms for each plant, we need to then figure out which turbine(s) had the most instances of that alarm go off in the same time period. 

4. The final output is basically Plant Name, Alarm Code, # of alarms, and Turbine(s) most impacted. That would look like this:

 

 

Here's how the data flow would work from start to finish:

 

First, the raw data. This is just 2 days with 2 plants, 3 alarms and 3 turbines per plant:

 

So the next step is to count total number of alarms per plant for the given date range. Ultimately, we only care about the top 2 for each plant:

 

We now need to count the total number of alarms per turbine, to know which match up with our most common alarms:

 

 

Now we need only those which were part of the most common alarms (AC1, AC2):

 

And then again, the final data set which shows the most common alarms per plant, with a column for the turbine(s) which were most affected by those alarms:

 

 

I feel like this shouldn't be too difficult to do, it took about 2 minutes wo work up Access queries to show the data I need, but the tricky part is dealing with selecting any date range to begin with. In my example here it's just 2 days and I selected them both, but in reality we'll have year(s) worth of data and the user should use a slider to pick any date range they want, and then these same calculations need to happen.

 

Thank you so much if you can help!

 

thanks

Alex

 

  • itsmebvk's avatar
    itsmebvk
    7 years ago


    Anonymous

     

    Here is what I am doing,

     

     

    1)Create a measure called "Rank Alarm Code" using following code :

     

    Rank Alarm Code = RANKX(ALLSELECTED(Sheet1[Alarm_Code]),CALCULATE(sum(Sheet1[Alarm_Count]),ALLSELECTED(Sheet1[Turbine])),, DESC) 

     


    2)Create another measure called "Rank Turbines" using following code :

     

    Rank Turbine = RANKX(ALLSELECTED(Sheet1[Turbine]),CALCULATE(SUM(Sheet1[Alarm_Count])))


    3)Create one more measure called "Total Alarms" using following code:

     

    Total Alarms = CALCULATE(SUM(Sheet1[Alarm_Count]),ALL(Sheet1[Turbine]))


    4) Filter (visual/Report/Page) on "Rank alarm Code"<=2

    5) Filter (visual/Report/Page) on "Rank Turbine"=1

    6)Add "Total Alarms" to the report.

     

    You should get output as shown in the screen shot.

     

     

    I am also trying to explore PowerBI more, please correct me if i misunderstood your requirement. I was unable to upload PBX as i don't have permissions.

  • Hi,

     

    You may download my PBI file from here.  For Plant 2, AC3 should also show up because of a tie - 32 alarms.

     

    Hope this helps.

     

  • Anonymous's avatar
    Anonymous
    7 years ago

    Wow! This is fantastic, thank you so much!

14 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      I just got back to my desk and haven't followed that link yet (but surely will, thank you!), but assume you want the data - I should have thought of that. Attached is a spreadsheet with the original base data, as well as all of the data used in my prior images. Hopefully that helps, and if it does, thank you very much!

       

      Alex

       

      p.s. I couldn't figure how to upload an Excel file so I did read the above post on how to get the best possible answer, so I'll paste from excel below and hope for the best...

       

      Raw Data
      PlantDateAlarm_CodeTurbineAlarm_count
      Plant11/1/2018AC1T15
      Plant11/1/2018AC1T21
      Plant11/1/2018AC1T37
      Plant11/1/2018AC2T11
      Plant11/1/2018AC2T210
      Plant11/1/2018AC2T33
      Plant11/1/2018AC3T11
      Plant11/1/2018AC3T210
      Plant11/1/2018AC3T33
      Plant11/2/2018AC1T121
      Plant11/2/2018AC1T20
      Plant11/2/2018AC1T312
      Plant11/2/2018AC2T15
      Plant11/2/2018AC2T29
      Plant11/2/2018AC2T31
      Plant11/2/2018AC3T11
      Plant11/2/2018AC3T22
      Plant11/2/2018AC3T35
      Plant21/1/2018AC1T16
      Plant21/1/2018AC1T215
      Plant21/1/2018AC1T314
      Plant21/1/2018AC2T16
      Plant21/1/2018AC2T215
      Plant21/1/2018AC2T32
      Plant21/1/2018AC3T18
      Plant21/1/2018AC3T26
      Plant21/1/2018AC3T314
      Plant21/2/2018AC1T120
      Plant21/2/2018AC1T217
      Plant21/2/2018AC1T38
      Plant21/2/2018AC2T14
      Plant21/2/2018AC2T220
      Plant21/2/2018AC2T320
      Plant21/2/2018AC3T15
      Plant21/2/2018AC3T23
      Plant21/2/2018AC3T318

       

       

      Top 2 Alarms by plant
      PlantAlarm_CodeAlarm_count
      Plant1AC146
      Plant1AC229
      Plant1AC322
      Plant2AC180
      Plant2AC267
      Plant2AC354

       

       

      All alarms by Turbine
      PlantTurbineAlarm_CodeAlarm_Count
      Plant1T1AC126
      Plant1T1AC26
      Plant1T1AC32
      Plant1T2AC11
      Plant1T2AC219
      Plant1T2AC312
      Plant1T3AC119
      Plant1T3AC24
      Plant1T3AC38
      Plant2T1AC126
      Plant2T1AC210
      Plant2T1AC313
      Plant2T2AC132
      Plant2T2AC235
      Plant2T2AC39
      Plant2T3AC122
      Plant2T3AC222
      Plant2T3AC332

       

       

      Join turbine data back to top alarms to find most impacted Turbines
      PlantAlarm_CodeTurbineTotalAlarmsTurbineAlarms
      Plant1AC1T14626
      Plant1AC1T34619
      Plant1AC1T2461
      Plant1AC2T22919
      Plant1AC2T1296
      Plant1AC2T3294
      Plant2AC1T28032
      Plant2AC1T18026
      Plant2AC1T38022
      Plant2AC2T26735
      Plant2AC2T36722
      Plant2AC2T16710

       

       

      Final dataset
      PlantAlarm_CodeTotalAlarmsMost impacted Turbine(s)
      Plant1AC146T1
      Plant1AC229T2
      Plant2AC180T2
      Plant2AC267T2
      • itsmebvk's avatar
        itsmebvk
        Continued Contributor


        Anonymous

         

        Here is what I am doing,

         

         

        1)Create a measure called "Rank Alarm Code" using following code :

         

        Rank Alarm Code = RANKX(ALLSELECTED(Sheet1[Alarm_Code]),CALCULATE(sum(Sheet1[Alarm_Count]),ALLSELECTED(Sheet1[Turbine])),, DESC) 

         


        2)Create another measure called "Rank Turbines" using following code :

         

        Rank Turbine = RANKX(ALLSELECTED(Sheet1[Turbine]),CALCULATE(SUM(Sheet1[Alarm_Count])))


        3)Create one more measure called "Total Alarms" using following code:

         

        Total Alarms = CALCULATE(SUM(Sheet1[Alarm_Count]),ALL(Sheet1[Turbine]))


        4) Filter (visual/Report/Page) on "Rank alarm Code"<=2

        5) Filter (visual/Report/Page) on "Rank Turbine"=1

        6)Add "Total Alarms" to the report.

         

        You should get output as shown in the screen shot.

         

         

        I am also trying to explore PowerBI more, please correct me if i misunderstood your requirement. I was unable to upload PBX as i don't have permissions.