Forum Discussion

KIMPD's avatar
KIMPD
Advocate II
8 years ago
Solved

Show last value in Cards

Hi, 

 

I have difficulties with the card visualisation. I have a datasets which only contains binary values 0 and 1 for a certain period. I have converted these values in 0 --> error and 1--> OK! by making a new column with:

 

Status = IF(health[Code]=1;"Error";"OK!")

 

Next I tried to put this in a card and I wanted it to show only the last status. So for example,

 

5-6-2017 = Error

8-9-2017 = Error

31-12-201 = OK!

 

The status should thus be OK! However, I noticed the card only shows maximum or minimum value during that period and not the last value of that period. In the example, the card would only show Error; the maximum value of during the whole period.

I have tried to set the field in "last" or "first", but both did not work for me.

 

Could anyone help me?

  • Hi KIMPD,

     

    You can create a measure below, then put this measure in a card visual. For details, you can download attached pbix file. 

     

    Measure = var maxP=CALCULATE(MAX('Table1'[Period]),ALLSELECTED(Table1))
    return
    CALCULATE(MAX('Table1'[Status]),FILTER('Table1','Table1'[Period]=maxP))

     

     

     

    Best Regards,
    Qiuyun Yu 

6 Replies

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

    Hi KIMPD,

     

    Assume the data below: 

     

     

    In Power BI desktop version 2.51.4885.701 64-bit (October 2017), after place the Status calculated column to the card visual and set Last aggregation, it displays OK. You can see attached pbix file. 

     

     

    Best Regards,
    Qiuyun Yu 

    • KIMPD's avatar
      KIMPD
      Advocate II

      Dear v-qiuyu-msft,

       

      I have already tried that (I also mentioned this in the opening post:

      "The status should thus be OK! However, I noticed the card only shows maximum or minimum value during that period and not the last value of that period. In the example, the card would only show Error; the maximum value of during the whole period.

      I have tried to set the field in "last" or "first", but both did not work for me.")

       

      Indeed this will cause the card to change in OK!, however, when you add for example a slicer and you change the period, the value will be the highest or the lowest value: see attachement. 

       

       

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

        Hi KIMPD,

         

        You can create a measure below, then put this measure in a card visual. For details, you can download attached pbix file. 

         

        Measure = var maxP=CALCULATE(MAX('Table1'[Period]),ALLSELECTED(Table1))
        return
        CALCULATE(MAX('Table1'[Status]),FILTER('Table1','Table1'[Period]=maxP))

         

         

         

        Best Regards,
        Qiuyun Yu 

  • Omega's avatar
    Omega
    Impactful Individual

    Shouldn't Status = IF(health[Code]=1;"OK!";"Error") ?

    • KIMPD's avatar
      KIMPD
      Advocate II

      No, that is just the matter of definition of my system.