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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Kolumam
Post Prodigy
Post Prodigy

DAX formula to retreive a value of a column based on a date field in another column

How do I retreive a value of a column based on the most recent date of another column ?

1 ACCEPTED SOLUTION

Hi @Kolumam

 

replace [Last_Date] in the last line with just secondLast_Date

 

secondLast_Date should be without brackets because it is the variable in the same formula

 

 

 

 

 

 

View solution in original post

13 REPLIES 13
Zubair_Muhammad
Community Champion
Community Champion

Hi @Kolumam

 

Do you mean Column or Table?

 

Please could you paste 5-6 rows of sample data and expected result?

WhatsApp Image 2017-11-27 at 6.22.37 PM.jpeg

So there are two columns here. The measure should display the value of "Percentage Solar over Load" based on the most recen date (i.e. 27/11/2017)

HI @Kolumam

 

Please try these MEASURES.

I am assuming Percentage Solar Over Load is a MEASURE

 

 

LastDate =
LASTDATE ( ALL ( Table1[Date] ) )

 

%age on LastDate=
VAR Last_Date =
    LASTDATE ( ALL ( Table1[Date] ) )
RETURN
    CALCULATE ( [Percentage Solar over Load], Table1[Date] = Last_Date )

Hi Zubair,

 

Percentage Solar over load is just a column from excel sheet.

Hi Zubair

 

Instead of retreiving the value based on the most recet date, is it possible to retreive based on yesterday date ? (26/11/2017)

Hi @Kolumam

 

Just Wrap LastDate with PreviousDay

 

 

Last_Date = PREVIOUSDAY(LastDate(All(Table1[Date])))

 

@Kolumam

 

SecondLastDate =
PreviousDay(LASTDATE ( ALL ( Table1[Date] ) ))

 

%age on SecondLastDate=
VAR SecondLast_Date =
    PreviousDay(LASTDATE ( ALL ( Table1[Date] ) ))
RETURN
    CALCULATE ( [Percentage Solar over Load], Table1[Date] = SecondLast_Date )

MR.PNG

 

Not sure why it is able to find the column ?

@Kolumam

 

So its a Column. I thought its a MEASURE

 

Use Calculate(sum(Meter REadings[Percentage Solar Overload])

 

calculate cannot have simple columns as arguments

MD.PNG

 

It gives me this error now.

Hi @Kolumam

 

replace [Last_Date] in the last line with just secondLast_Date

 

secondLast_Date should be without brackets because it is the variable in the same formula

 

 

 

 

 

 

I realized the mistake yesterday itself. Thanks for your immense help.

Hi Zubair,

 

The formula that you suggested a few months back is not working now. all of a sudden it has gone blank. It says data format is not supported.

 

Could you please help me with my query ?

http://community.powerbi.com/t5/Desktop/Error-with-DAX-formula/m-p/338849#M151633

 

Thanks

Krishna

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors