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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Allisond
Advocate II
Advocate II

Pulling forward last entered value to date by date day

Good Morning,
 
I have a Measure set up to pull forward the most recently entered value until a new value is entered. 
 
ID                Date                  Value
123             01/01/20            3
123             01/03/20            1
123             01/06/20            2
 
Result should look like this:
01/01/20     01/02      01/ 03       01/04      01/05    01/06      01/07
    3            3          1           1         1         2          2
 
 
I have set up my measure as:
 
Measure =
VAR FirstVisibleDate = MIN(Dates[DayDate])
VAR PreviousDate = CALCULATE(MAX(Table[Value Date]), Dates[DayDate]<=FirstVisibleDate)
VAR FilterPreviousDate = TREATAS({PreviousDate},Dates[DayDate])
VAR Result = CALCULATE([Latest Value],FilterPreviousDate)
 
RETURN
Result
 
[Latest Value Date] is a simple measure calculating the LastNonBlank
 
However, my result is only showing the latest dates appropriately.  My first values are blank.  
 
Actual Result: 
01/01/20      01/02       01/ 03       01/04      01/05     01/06      01/07
                                                              2           2
 
Can anyone else see what is wrong with my measure?   Thank you for any help!
 
1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Allisond,

 

Try this approach.

 

1. Create measure. Table2 is the data table, and has a relationship with Dates.

Latest Value = 
VAR vCurrentDate =
    MAX ( Dates[Date] )
VAR vMaxDateCurrentID =
    CALCULATE (
        MAX ( Table2[Date] ),
        ALLSELECTED ( Dates[Date] ),
        Table2[Date] <= vCurrentDate
    )
VAR vMaxValueCurrentID =
    CALCULATE (
        MAX ( Table2[Value] ),
        ALLSELECTED ( Dates[Date] ),
        Table2[Date] = vMaxDateCurrentID
    )
RETURN
    vMaxValueCurrentID

 

2. Create matrix visual and date slicer. Columns in matrix should be Dates[Date], and set to "Show items with no data".

 

DataInsights_1-1604421311640.png

 

DataInsights_2-1604421328649.png

 

 

Sample data:

 

DataInsights_0-1604421242249.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
DataInsights
Super User
Super User

@Allisond,

 

Try this approach.

 

1. Create measure. Table2 is the data table, and has a relationship with Dates.

Latest Value = 
VAR vCurrentDate =
    MAX ( Dates[Date] )
VAR vMaxDateCurrentID =
    CALCULATE (
        MAX ( Table2[Date] ),
        ALLSELECTED ( Dates[Date] ),
        Table2[Date] <= vCurrentDate
    )
VAR vMaxValueCurrentID =
    CALCULATE (
        MAX ( Table2[Value] ),
        ALLSELECTED ( Dates[Date] ),
        Table2[Date] = vMaxDateCurrentID
    )
RETURN
    vMaxValueCurrentID

 

2. Create matrix visual and date slicer. Columns in matrix should be Dates[Date], and set to "Show items with no data".

 

DataInsights_1-1604421311640.png

 

DataInsights_2-1604421328649.png

 

 

Sample data:

 

DataInsights_0-1604421242249.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you so much for looking at this!

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.