Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Card Showing Last value

Dear Team

kindly need ur help
i want to create card , but only showing last value. 

ex if i choose this month , will show only last value which was entry for the last within this month .

my table like below

 

Thanks in advance

Regards

Syaiful Efendi

  • Hey Anonymous ,

     

       Thanks for reaching out.

      

        So the solution to this I think depends partially on your data and how it is feeding in. In your example data it looks like your data source is feeding in chronologically which makes things easier. The solution I would suggest would work in the event your data does load chronologically but you for some reason have two entries on a single day and would like to present the last one. This solution would also work for cases where your data is a single row per day as well

     

         First here is the sample data I'm working with

     

     

    Notice in this dataset I've added two entries for July 6th, 2020

     

    First lets open the query editor and index the data in this table from 1 by selecting the following

     

     

    Now that gives us an index column to reference

     

     

     

    So we will make a measure returning the rem.point value from the highest index

     

    Last Rem Point =
    
    var TheLastIndex = MAX(TestData[Index])
    
    return
    
    CALCULATE(MAX(TestData[Rem.Point]), TestData[Index] = TheLastIndex)

     

    Place that measure in a card visual and you will get the following

     

     

     

    If you wanted to have some text next to the value you could also write this measure and put it in a card visual

     

    Last Rem Point w/Text = 
    
    var TheLastIndex = MAX(TestData[Index])
    
    return
    
    "Last Rem Point: "&CALCULATE(MAX(TestData[Rem.Point]), TestData[Index] = TheLastIndex)

     

    That would give you the following

     

     

     

    Let me know if this or another posted solution works for you!

4 Replies

  • Hey Anonymous ,

     

       Thanks for reaching out.

      

        So the solution to this I think depends partially on your data and how it is feeding in. In your example data it looks like your data source is feeding in chronologically which makes things easier. The solution I would suggest would work in the event your data does load chronologically but you for some reason have two entries on a single day and would like to present the last one. This solution would also work for cases where your data is a single row per day as well

     

         First here is the sample data I'm working with

     

     

    Notice in this dataset I've added two entries for July 6th, 2020

     

    First lets open the query editor and index the data in this table from 1 by selecting the following

     

     

    Now that gives us an index column to reference

     

     

     

    So we will make a measure returning the rem.point value from the highest index

     

    Last Rem Point =
    
    var TheLastIndex = MAX(TestData[Index])
    
    return
    
    CALCULATE(MAX(TestData[Rem.Point]), TestData[Index] = TheLastIndex)

     

    Place that measure in a card visual and you will get the following

     

     

     

    If you wanted to have some text next to the value you could also write this measure and put it in a card visual

     

    Last Rem Point w/Text = 
    
    var TheLastIndex = MAX(TestData[Index])
    
    return
    
    "Last Rem Point: "&CALCULATE(MAX(TestData[Rem.Point]), TestData[Index] = TheLastIndex)

     

    That would give you the following

     

     

     

    Let me know if this or another posted solution works for you!

  • FarhanAhmed's avatar
    FarhanAhmed
    Community Champion
    _Amount = 
    Var Dt = MAX(RunningTotal[Date])
    RETURN
    CALCULATE(SUM(RunningTotal[Amount]),RunningTotal[Date]=Dt)

     

    This will return total of the last that you selected.

     

    But if you always want to return single row value, then you need to add Index Column in your table using Power Query

    https://docs.microsoft.com/en-us/powerquery-m/table-addindexcolumn

     

    And replace the date filter from above formula to get Max Index and Filtered Index.

  • Hi Anonymous ,

     

    Create a measure using following DAX expression and move it to your card visual:

    Last Value for Month = CALCULATE(SUM(Tablename[Start.Point]), FILTER(Tablename, Tablename[Date] = ENDOFMONTH(Tablename[Date])))
     
    Just make sure to give your column names and table name in above expression. I have highlighted them.
     
    Thanks,
    Pragati