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
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

 

 

 

 

 

 


Regards
Zubair

Please try my custom visuals

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?


Regards
Zubair

Please try my custom visuals

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 )

Regards
Zubair

Please try my custom visuals

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])))

 


Regards
Zubair

Please try my custom visuals

@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 )

Regards
Zubair

Please try my custom visuals

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


Regards
Zubair

Please try my custom visuals

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

 

 

 

 

 

 


Regards
Zubair

Please try my custom visuals

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
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.