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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Obtain Last End of Month Value

mf23456_0-1666808776553.png

I have attached mock data for better explanation. My data is reported daily, multiple times a day, with no consistency of the time of day. I want to create a table showing the last value reported for each month (indicated in the image by highlighted values). This would be the cell highlighted above, NOT a sum of the month NOR sum of the day. Does anyone know a way to do this?

 

1 ACCEPTED SOLUTION

@Anonymous ,

Please modify the new Table as this:

LastValuesTable5a = SUMMARIZECOLUMNS( Table5a[Year-Month], Table5a[Type],
                            "LastDate", CALCULATE( MAX( Table5a[Date] ),
                                         FILTER(Table5a, Table5a[id] = MAX(Table5a[id]))),
                            "LastValue", CALCULATE( MAX( Table5a[Amount] ), 
                                         FILTER( Table5a, Table5a[id] = MAX( Table5a[id] ))))

LastDateLastValueYear-MonthType

1/19/2022 10:01:22 PM 2.4 2022-01 b
1/31/2022 11:01:22 PM 1.9 2022-01 a
2/19/2022 10:01:22 PM 4.3 2022-02 b
2/28/2022 11:01:22 PM 3.7 2022-02 a

Also, Feb only has 28 days, not 31.  Ensure your DateTime column is formatted as such and not Text.

Regards,

View solution in original post

8 REPLIES 8
rsbin
Super User
Super User

@Anonymous ,

First create a Calculated Column to obtain year-month:

Year-Month = FORMAT( [Date], "yyyy-mm" )

I am assuming your data will eventually cross years.  If not, then perhaps you just need a Month column.

Then I created a Summary Table:

LastValuesTable5 = SUMMARIZECOLUMNS( Table5[Year-Month],
                    "LastDate", MAX( Table5[Date] ),
                     "LastValue", CALCULATE( MAX( Table5[Amount] ), 
                                     FILTER( Table5, Table5[Date] = MAX( Table5[Date] ))))

Replace 'Table5' with the name of your table. I believe this is the result you are looking for:

Year-Month           LastDate              LastValue

2022-01 1/31/2022 12:01:59 AM 2.46
2022-02 2/28/2022 12:24:00 PM 9.54

 

Regards,

Anonymous
Not applicable

For the creation of a summary table, where would i put that formula in? In Power Query or in the main power bi page?

@Anonymous ,

In Power BI

rsbin_0-1666812661145.png

Select New Table.

 

Anonymous
Not applicable

Thank you. I found another obstacle. Some of the dates & times are exactly the same. How can I adjust the formula to take the very last day & time input even when the days and times are the same? I can draft mock data if that's easier too

@Anonymous ,

Don't quite understand the obstacle.  If the last date and time are the exact same for more than one record, what are you using to decide which record to keep?

Please post mock data, but post it as a table, not as a picture.  Keep this in mind for all future posts.

Anonymous
Not applicable

TypeDateamountid
a1/1/2022  21:11:22 PM11
a1/5/2022  21:59:22 PM22
b1/11/2022  22:01:22 PM1.13
b1/19/2022  22:01:22 PM2.43
a1/31/2022  23:01:22 PM1.54
a1/31/2022  23:01:22 PM1.95
a2/1/2022  21:11:22 PM2.56
a2/5/2022  21:59:22 PM2.87
b2/11/2022  22:01:22 PM6.48
b2/19/2022  22:01:22 PM4.39
a2/31/2022  23:01:22 PM8.510
a2/31/2022  23:01:22 PM3.711

Here is a new mock table. I have 2 different item types (a & b). There are some dates&times that are exact and only distinguishable by ID column. This way, I can create a power bi table with the last recorded amounts for each item for each month. the data results are as shown below: (Thank you again!!)

TypeDateamountid
b1/19/2022  22:01:22 PM2.43
a1/31/2022  23:01:22 PM1.95
b2/19/2022  22:01:22 PM4.39
a2/31/2022  23:01:22 PM3.711

@Anonymous ,

Please modify the new Table as this:

LastValuesTable5a = SUMMARIZECOLUMNS( Table5a[Year-Month], Table5a[Type],
                            "LastDate", CALCULATE( MAX( Table5a[Date] ),
                                         FILTER(Table5a, Table5a[id] = MAX(Table5a[id]))),
                            "LastValue", CALCULATE( MAX( Table5a[Amount] ), 
                                         FILTER( Table5a, Table5a[id] = MAX( Table5a[id] ))))

LastDateLastValueYear-MonthType

1/19/2022 10:01:22 PM 2.4 2022-01 b
1/31/2022 11:01:22 PM 1.9 2022-01 a
2/19/2022 10:01:22 PM 4.3 2022-02 b
2/28/2022 11:01:22 PM 3.7 2022-02 a

Also, Feb only has 28 days, not 31.  Ensure your DateTime column is formatted as such and not Text.

Regards,

Anonymous
Not applicable

Oops. The Feb 31st was due to me typing in mock data. Thank you so much! This worked. I really appreciate your assistance.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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