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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
PhilippMer
Frequent Visitor

Dax Function retrieve value from previous entry

Hello, I have come across a problem, and im not able to find the right expression in DAX to solve it so far. 

I have a Table with Data from a LinkedIn profile, there are over 90 different Posts and the corresponding amount of Views on every single day. I would like a Column to have the the Value of the amount of Views from the previews day, so that I can make a simple Calculation of how many new Views per day each post had. My table looks like the following:

PhilippMer_0-1654844068774.png

I tried going through the LogDate with Earlier...but so far had no success. There is no ID only the PostText as a String. Any recommendations on how I could get to the solution?

 

Thanks in advance!

1 ACCEPTED SOLUTION

@PhilippMer 

Sorry my mistake 

Previous Day Views =
VAR CurrentDate = TableName[LogDate]
VAR PostTable =
    CALCULATETABLE ( TableName, ALLEXCEPT ( TableName, TableName[PostText] ) )
VAR PreviousDate =
    MAXX (
        FILTER ( PostTable, TableName[LogDate] < CurrentDate ),
        TableName[LogDate]
    )
RETURN
    MAXX (
        FILTER ( PostTable, TableName[LogDate] = PreviousDate ),
        TableName[PostViews]
    )

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @PhilippMer 

please use

Previous Day Views =
VAR CurrentDate = TableName[LogDate]
VAR PostTable =
    CALCULATETABLE ( TableName, ALLEXCEPT ( TableName, TableName[PostText] ) )
VAR PreviousDate =
    MAXX (
        FILTER ( PostTable, TableName[LogDate] < CurrentDate ),
        TableName[LogDate]
    )
RETURN
    MAXX (
        FILTER ( PostTable, TableName[LogDate] < PreviousDate ),
        TableName[PostViews]
    )

Hi @tamerj1 

thank you so much for your quick reply. The formula almost works as expected. I think for some reason it takes the Numbers 2 entries from before and not the first entrie before of the current date. 

Screenshot: 

PhilippMer_0-1654845241566.pngPhilippMer_1-1654845253927.png

Do you know why this is happening?

@PhilippMer 

Sorry my mistake 

Previous Day Views =
VAR CurrentDate = TableName[LogDate]
VAR PostTable =
    CALCULATETABLE ( TableName, ALLEXCEPT ( TableName, TableName[PostText] ) )
VAR PreviousDate =
    MAXX (
        FILTER ( PostTable, TableName[LogDate] < CurrentDate ),
        TableName[LogDate]
    )
RETURN
    MAXX (
        FILTER ( PostTable, TableName[LogDate] = PreviousDate ),
        TableName[PostViews]
    )

Thank you @tamerj1 you saved my day! 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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