Forum Discussion

Klasia's avatar
Klasia
Frequent Visitor
1 year ago
Solved

Dynamic quantile calculation and matrix marking

Hi. I have in my Power BI matrix, where from each category and type I want show in which row i have median and quantiles (0,25; 0,95).
All value in time I have coating in measure because must be dinamic, depence what you choose in filters

 

My matrix:

TypCategoryTaskTime A [s]
Type A   
 Category A 
  Task 125
  Task 236
  Task 320
 Category B  
  Task 110
Type B   
 Category C  
  Task 15
  Task 23
  Task 38
  Task 420
  Task 59
  Task 617

 

And I Want add columns like

TypCategoryTaskTime A [s]MedianQuantile 0.25Quantile 0.95
Type A      
 Category A    
  Task 125MedianQuantile 0.25 
  Task 236  Quantile 0.95
  Task 320   
 Category B     
  Task 110MedianQuantile 0.25Quantile 0.95
Type B      
 Category C     
  Task 15 Quantile 0.25 
  Task 23   
  Task 38Median  
  Task 420   
  Task 59   
  Task 617  Quantile 0.95

 

I don't know how to compare values ​​at the task level with the value calculated at the category level

 

 

  • Hi Klasia,

    Thank you for reaching out to the Microsoft Fabric Forum Community.

    Thank you pankajnamekar25, for your valuable insights.

    I have reproduced the scenario using sample data. Please find the attached pbix file for your reference.

     

    If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.

     

    Thank you.

6 Replies

  • Hello Klasia 

    You have to create one measure of each calculations.

     

    Median Calculation

    Median Time =

    CALCULATE(

        MEDIAN(Tasks[Time A [s]]),

        ALLEXCEPT(Tasks, Tasks[Category])

    )

    0.25 Quantile Calculation (25th Percentile)

    DAX doesn’t have a direct quantile function, but you can create a measure using PERCENTILEX.INC:

    Quantile 0.25 =

    CALCULATE(

        PERCENTILEX.INC(

            FILTER(Tasks, NOT(ISBLANK(Tasks[Time A [s]]))),

            Tasks[Time A [s]],

            0.25

        ),

        ALLEXCEPT(Tasks, Tasks[Category])

    )

     0.95 Quantile Calculation (95th Percentile)

    Quantile 0.95 =

    CALCULATE(

        PERCENTILEX.INC(

            FILTER(Tasks, NOT(ISBLANK(Tasks[Time A [s]]))),

            Tasks[Time A [s]],

            0.95

        ),

        ALLEXCEPT(Tasks, Tasks[Category])

    )

    Mark Median

    Mark Median =

    IF(

        SELECTEDVALUE(Tasks[Time A [s]]) = [Median Time],

        "Median",

        BLANK()

    )

    Mark Quantile 0.25

    Mark Quantile 0.25 =

    IF(

        SELECTEDVALUE(Tasks[Time A [s]]) <= [Quantile 0.25],

        "Quantile 0.25",

        BLANK()

    )

    Mark Quantile 0.95

    Mark Quantile 0.95 =

    IF(

        SELECTEDVALUE(Tasks[Time A [s]]) >= [Quantile 0.95],

        "Quantile 0.95",

        BLANK()

    )

    Thanks,
     Pankaj Namekar | LinkedIn

    If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

     

  • Klasia's avatar
    Klasia
    Frequent Visitor

    Thanks pankajnamekar25 , but I don't know what I do wrong in Median Time, because show me wrong value

    And I do exactly how you wrote

     

    EDIT: I chage ALLEXCEPT to  ALLSELECTED and now working. 

    • v-saisrao-msft's avatar
      v-saisrao-msft
      Community Support

      Hi Klasia,

      Thank you for reaching out to the Microsoft Fabric Forum Community.

      Thank you pankajnamekar25, for your valuable insights.

      I have reproduced the scenario using sample data. Please find the attached pbix file for your reference.

       

      If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.

       

      Thank you.

      • v-saisrao-msft's avatar
        v-saisrao-msft
        Community Support

        Hi Klasia,

         

        We haven’t heard back from you regarding your issue. If it has been resolved, please mark the helpful response as the solution and give a ‘Kudos’ to assist others. If you still need support, let us know.

         

        Thank you.

    • v-saisrao-msft's avatar
      v-saisrao-msft
      Community Support

      Hi Klasia,

      May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

      Thank you.

  • v-saisrao-msft's avatar
    v-saisrao-msft
    Community Support

    Hi Klasia,
    I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
    Thank you.