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
rushkarausch
Regular Visitor

DAX Lookup within Date Range

hi, i have this Table1 that shows reservehist changes occured on each datehist

 

DateHistReserveHist
02/05/2023505
03/05/202311005
15/05/20236505
02/06/20238007.2
14/06/20238207.2
26/06/20238092.2
28/06/20237867.2

 

how do i create the column on the right below? i need this column to read from the table above - for example, 17/05/2023 falls between 15/05 and 02/06, that means the value should be 6505.  
the last change happened on 28/06, so any dates below after 28/06 should show 7867.2

DateHow to Create This Column?
17/05/20236505
18/05/20236505
02/06/20238007.2
14/06/20238207.2
26/06/20238092.2
28/06/20237867.2
27/07/20237867.2
22/08/20237867.2


does anyone have any ideas? 

1 ACCEPTED SOLUTION

Actually i resolved it myself taking a direction from your query - thanks so much was very helpful. 
for anyone interested, this was the solution that worked perfectly.
i jsut needed to add an additional ID column as well to the tables, but you can just remove those bits from this query below and use it. 

ReserveHistValue =
CALCULATE(
    LASTNONBLANK('Reserve History'[Section5 Removed], 1),
    FILTER(
        'Reserve History',
        'Reserve History'[FactCaseReserveHistory[Caseref]]] = EARLIER('UNION'[CLAIM_REFERENCE_SUPPLIER]) &&
        'Reserve History'[FactCaseReserveHistory[AuditTimeStamp]]]=
        MAXX(
            FILTER(
                'Reserve History',
                'Reserve History'[FactCaseReserveHistory[Caseref]]] = EARLIER('UNION'[CLAIM_REFERENCE_SUPPLIER]) &&
                'Reserve History'[FactCaseReserveHistory[AuditTimeStamp]]] <= EARLIER('UNION'[BOOKING_DATE_SUPPLIER])),
            'Reserve History'[FactCaseReserveHistory[AuditTimeStamp]]]
            )
          )
        )

View solution in original post

3 REPLIES 3
bhanu_gautam
Super User
Super User

@rushkarausch ,Try using below method

 



ReserveHistValue =
VAR SelectedDate = SELECTEDVALUE('DateTable'[Date])
RETURN
CALCULATE(
LASTNONBLANK('Table1'[ReserveHist], 1),
FILTER(
ALL('Table1'),
'Table1'[DateHist] <= SelectedDate
)
)





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

Proud to be a Super User!




thanks for your reply, but this didnt work sadly 😞 any suggestions why? 

rushkarausch_0-1715213800679.png

 

Actually i resolved it myself taking a direction from your query - thanks so much was very helpful. 
for anyone interested, this was the solution that worked perfectly.
i jsut needed to add an additional ID column as well to the tables, but you can just remove those bits from this query below and use it. 

ReserveHistValue =
CALCULATE(
    LASTNONBLANK('Reserve History'[Section5 Removed], 1),
    FILTER(
        'Reserve History',
        'Reserve History'[FactCaseReserveHistory[Caseref]]] = EARLIER('UNION'[CLAIM_REFERENCE_SUPPLIER]) &&
        'Reserve History'[FactCaseReserveHistory[AuditTimeStamp]]]=
        MAXX(
            FILTER(
                'Reserve History',
                'Reserve History'[FactCaseReserveHistory[Caseref]]] = EARLIER('UNION'[CLAIM_REFERENCE_SUPPLIER]) &&
                'Reserve History'[FactCaseReserveHistory[AuditTimeStamp]]] <= EARLIER('UNION'[BOOKING_DATE_SUPPLIER])),
            'Reserve History'[FactCaseReserveHistory[AuditTimeStamp]]]
            )
          )
        )

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.

Top Solution Authors