Forum Discussion

TornDigorn's avatar
TornDigorn
Frequent Visitor
3 years ago
Solved

Custom KPI card - difference based on the previous month

Hello PBI community, 

 

I would like to create a custom KPI card that will show the difference in number + percentage difference for the current month vs. the previous one.

 

For example, clicking on February, the difference in the custom KPI card should be

4.32 = 100%
3.21 = 74.3 %
200 - 74.3 % = 25.7%

 

Custom KPI card for February
- 1.11
- 25.7 %

 

Thank you so much ! 

  • Hi , TornDigorn 

    According to your descriptin, you want to custom the KPI card , and you want to show the differnce and the percentage in KPI card.

    After my test, KPI displays Value and Goal by default, and there is no Difference:

    So for your need , you can follow this to create a custom KPI card:
    Custom KPI card in Power BI - Data Bear - Power BI Training

     

    And i can give your the dax code to get the  differnce and the percentage:

    Difference = var _date = MAX('Table'[Date])
    var _t = FILTER( ALL('Table'), YEAR('Table'[Date]) = YEAR(_date) && MONTH('Table'[Date])=MONTH(_date)-1)
    
    return
    CALCULATE( AVERAGE('Table'[Final Days]) ,  YEAR('Table'[Date]) = YEAR(_date) , MONTH('Table'[Date])=MONTH(_date)) - AVERAGEX(_t,[Final Days])
    Percentage = var _date = MAX('Table'[Date])
    var _t = FILTER( ALL('Table'), YEAR('Table'[Date]) = YEAR(_date) && MONTH('Table'[Date])=MONTH(_date)-1)
    
    return
    DIVIDE(CALCULATE( AVERAGE('Table'[Final Days]) ,  YEAR('Table'[Date]) = YEAR(_date) , MONTH('Table'[Date])=MONTH(_date)) - AVERAGEX(_t,[Final Days]) ,AVERAGEX(_t,[Final Days]))

     

    The result is as follows:

     

     

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

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

1 Reply

  • Hi , TornDigorn 

    According to your descriptin, you want to custom the KPI card , and you want to show the differnce and the percentage in KPI card.

    After my test, KPI displays Value and Goal by default, and there is no Difference:

    So for your need , you can follow this to create a custom KPI card:
    Custom KPI card in Power BI - Data Bear - Power BI Training

     

    And i can give your the dax code to get the  differnce and the percentage:

    Difference = var _date = MAX('Table'[Date])
    var _t = FILTER( ALL('Table'), YEAR('Table'[Date]) = YEAR(_date) && MONTH('Table'[Date])=MONTH(_date)-1)
    
    return
    CALCULATE( AVERAGE('Table'[Final Days]) ,  YEAR('Table'[Date]) = YEAR(_date) , MONTH('Table'[Date])=MONTH(_date)) - AVERAGEX(_t,[Final Days])
    Percentage = var _date = MAX('Table'[Date])
    var _t = FILTER( ALL('Table'), YEAR('Table'[Date]) = YEAR(_date) && MONTH('Table'[Date])=MONTH(_date)-1)
    
    return
    DIVIDE(CALCULATE( AVERAGE('Table'[Final Days]) ,  YEAR('Table'[Date]) = YEAR(_date) , MONTH('Table'[Date])=MONTH(_date)) - AVERAGEX(_t,[Final Days]) ,AVERAGEX(_t,[Final Days]))

     

    The result is as follows:

     

     

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

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