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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
ania_roh
Helper III
Helper III

need help with dax formule

Hi,

I´m trying to calculate the last value of every ID KPI (with a measure), as I showed it in the picture:

ania_roh_0-1606476086937.png

I mean, the last  value is the value of the previos date, for every ID KPI, so I try to have that result:

ania_roh_1-1606476706646.png

 

¿ How can I do this? 

I tried to do that searching firstly the max of the date and then trying to find the max of other dates: 

= maxx (filter ('Medición KPIS', 'Medición KPIS'[Date] <> max ('Medición KPIS'[Date])), 'Medición KPIS'[Date])

But it didn´t work.

Is other way to do that?

Thank you a lot.

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ania_roh , Create a new column like

new column =
var _max = maxx(filter(Table, [date]<earlier([Date]) && [ID KPI] =earlier([ID KPI])),[Date])
return
maxx(filter(Table, [date] =_max && [ID KPI] =earlier([ID KPI])),[value])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

5 REPLIES 5
ania_roh
Helper III
Helper III

Sorry @amitachandak I put it wrong, it was my mistake. I really appreciate your help, thank you a lot. It really works! 

I put it as a solution.

 

Anonymous
Not applicable

@ania_roh  you can use this function .

last month sales = calculate(sum(financials[ Sales]),PREVIOUSDAY(financials[Date]))
in my case i am having monthly data so i am using previous month function . but you can use previousday.
Last month.JPG
Kindly mark it as  solution if it solved your problem .

@Anonymous  thank you for your reply but the period is diffent, it is sometimes three month, sometimes 6 month, it depends on KPI and of what day people put the date into excel, so it doesn´t work in this case, because it is variable always. 

 

amitchandak
Super User
Super User

@ania_roh , Create a new column like

new column =
var _max = maxx(filter(Table, [date]<earlier([Date]) && [ID KPI] =earlier([ID KPI])),[Date])
return
maxx(filter(Table, [date] =_max && [ID KPI] =earlier([ID KPI])),[value])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

@amitchandak could you please repeat the part after return...

I have a error in that part, but I don´t know why.

Thank you a lot. 

 

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.