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
Anonymous
Not applicable

Lead of MAx Date

Helo All,

 

My Data is like this and I need DAX calculation for  below :

 

IDWork ComletionLD1IS3is4ValueDate
2.1 StratificationWorkDown2011NULLNULL3223/1/2018
2.1 StratificationWorkDown2012NULLNULL2884/1/2018
2.1 StratificationWorkDown2013NULLNULL2885/1/2018
2.1 StratificationWorkDown2014NULLNULL1556/1/2018
2.1 StratificationWorkDown2015NULLNULL1427/1/2018

 

 

In the above table max(Date)=7/1/2018 & value=142 and previous month=6/1/2018 and value =155, i need previous month row value and max(Date row value) ina single line, something like below

 

 

IDWork ComletionLD1IS3is4ValueDateLead of Previosu month
2.1 StratificationWorkDown2011NULLNULL3223/1/2018null
2.1 StratificationWorkDown2012NULLNULL2884/1/2018null
2.1 StratificationWorkDown2013NULLNULL2885/1/2018null
2.1 StratificationWorkDown2014NULLNULL1556/1/2018null
2.1 StratificationWorkDown2015NULLNULL1427/1/2018

155

 

 

Please let me know if you need more info thanks

 

Shawn

1 ACCEPTED SOLUTION
v-danhe-msft
Employee
Employee

Hi @Anonymous,

Based on my test, you could refer to below steps:

Sample data:

1.PNG

Create a calculated column:

Last value = var a=DATE(YEAR('Table1'[Date]),MONTH('Table1'[Date])-1,DAY('Table1'[Date]))
             var b=CALCULATE(SUM(Table1[Value]),FILTER('Table1','Table1'[Date]=a))
             return IF([Date]=MAXX('Table1','Table1'[Date]),b,BLANK())

Now you could see the correct result:

2.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/dje61d7qncopqyu/Lead%20of%20MAx%20Date.pbix?dl=0

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-danhe-msft
Employee
Employee

Hi @Anonymous,

Based on my test, you could refer to below steps:

Sample data:

1.PNG

Create a calculated column:

Last value = var a=DATE(YEAR('Table1'[Date]),MONTH('Table1'[Date])-1,DAY('Table1'[Date]))
             var b=CALCULATE(SUM(Table1[Value]),FILTER('Table1','Table1'[Date]=a))
             return IF([Date]=MAXX('Table1','Table1'[Date]),b,BLANK())

Now you could see the correct result:

2.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/dje61d7qncopqyu/Lead%20of%20MAx%20Date.pbix?dl=0

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Seward12533
Solution Sage
Solution Sage

Look into earlier to retrieve previous values. There are lots of examples in the forum here is one.
https://community.powerbi.com/t5/Desktop/Previous-date-values/td-p/134347

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.