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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Aggregation of LATest (LAST) value

Hi all!

 

I´m new on Power Bi, I am migrating from Oracle (OBIEE) to Power BI.

In Oracle Business Intelligence (OBIEE) I can generate an aggregation with SUM and LAST. Taking the last value of the month for a given fact.

 

I need the last value for the month of January to be displayed in the month's aggregration value.

Does anyone have any idea how to do this?

I have researched several sources and forms but I have not been successful.

 

 

thank you in advance.


Example:
Sem título2.png

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Yes. lastdate can do that. First, prefer to have date table. And move all your month, year calculation there.

Now this lastdate takes row context. So if you select the month, it will give you month last date, If you display the date it will give you all the dates.

The second measure uses end of month and forces filter of that

 

Last day = CALCULATE([Sum Sales],LASTDATE('Date'[Date]))
end of month = CALCULATE([Sum Sales],filter('Date','Date'[Date]=endofmonth('Date'[Date])))

 

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

 
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
danextian
Super User
Super User

HI @Anonymous ,

 

You may create a calculated column to return the value of the last date of the month without regards to whether the date is the actual last date of the month in the calendar. 

 

First create a calculated column to group the dates into Year and Month - something like:

Month and Year = 
FORMAT ( 'Fact'[Date], "YYYYMM" )

And then another calculated column

Is Last Date? =
CALCULATE (
    LASTDATE ( 'Fact'[Date] ),
    ALLEXCEPT ( 'Fact', 'Fact'[Month and Year] )
) = 'Fact'[Date]

You may then use this calculated column to filter your aggregations. 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Anonymous
Not applicable

Hello @danextian , thanks for you reply!

 

I have this problem cause i´m using DirectQuery mode.

 

"The FORMAT function is not allowed as part of the calculated column DAX expressions in DirectQuery models"

 

 

 

erro.png

amitchandak
Super User
Super User

Yes. lastdate can do that. First, prefer to have date table. And move all your month, year calculation there.

Now this lastdate takes row context. So if you select the month, it will give you month last date, If you display the date it will give you all the dates.

The second measure uses end of month and forces filter of that

 

Last day = CALCULATE([Sum Sales],LASTDATE('Date'[Date]))
end of month = CALCULATE([Sum Sales],filter('Date','Date'[Date]=endofmonth('Date'[Date])))

 

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.

Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

 
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you so much @amitchandak ! 

 

It worked correctly both ways.

 

See below:

worked.png


Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.