Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Charles_625g
Frequent Visitor

Need to display the last record

We created a dashboard in Power BI Desktop to display the numeric values of various data points.  The data originates in SharePoint lists and is pulled into Power BI.  The issue is that there are multiple data values for each datapoint and to display the most recent data, we only want to show the last (most recent) data.  The figure below is an example the page in question.  It is a table visual that includes corresponding sparkline graphs.  Table visuals don’t provide an option for the last record. 

 

Charles_625g_0-1712235328000.png

 

 

We found two variants of a function for displaying the last record, but we are unable to get them to work (probably not getting the syntax right).

=Last(Fields!ProductNumber.Value, "Category")

= LAST(Products[Price], Products[Category])

 

The question is, how can we display only the last record for each line of data in the table shown above either using the function statements or some other method?

4 REPLIES 4
v-heq-msft
Community Support
Community Support

Hi @Charles_625g ,
According to your description, you want to get a VALUE value for a recent date.
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:

vheqmsft_0-1712305803363.png

Create a calculated column

 

Last Record = 
VAR _maxDate = MAXX(ALL('Table'),'Table'[Date])
RETURN
CALCULATE(
    MAX('Table'[Value]),
    FILTER(
        'Table',
        'Table'[Date] = _maxDate
        )
)

 

Final output

vheqmsft_1-1712305856132.png

 

Best regards,

Albert He

 

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

When I attempt to use this code in the table, I get the following error:

 

"A function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed."

 

How can I eliminate the error?  The rest of the code seems to be correct as far as syntax.  

 

 

 

Hi @Charles_625g ,
Thank you for your reply, based on the error message you provided, there is an issue with the way you are using true/false expressions in your DAX calculations.
I modified this dax a bit and you can try if it solves your problem

Rcord = 
VAR _date = MAX('Table'[Date])
RETURN
CALCULATE(
    MAX('Table'[Value]),
    FILTER(
        'Table',
        'Table'[Date] = _date
    )
)

Best regards,

Albert He

 

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

Thanks, this is helpful.  This code is more in line with other examples I have been finding.  Not familiar with the syntax so that is proving to be a challenge, but it gets us closer.  

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.