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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Leigh_G
Frequent Visitor

Max Value Associated with Most Recent Date

I have a standalone table of data (no date table in model) that has one date per month/year and sales for that date.  I am trying to create a card with the most recent sales figure (which should filter by date when date is used as a filter).

 

Here is the table:

Data Table.png

Here is the current report filtered by date and showing the current most recent period based on the date filter:

Table.png

 

Here is the code being used to generate the Most Recent Period measure:

Most Recent Period = CALCULATE(MAX('Advanced Retail Sales'[Date]),ALL('Advanced Retail Sales'[Advanced Retail Sales]))
 
Here is the code for the Last Value measure that is not working - it generates the 379K value when it should be 352K:
Last Value =
VAR d=CALCULATE(MAX('Advanced Retail Sales'[Date]),ALLSELECTED('Advanced Retail Sales'[Advanced Retail Sales]))
RETURN
LASTNONBLANK('Advanced Retail Sales'[Advanced Retail Sales],MAX('Advanced Retail Sales'[Date])=d)
 
Any solution?
 
 
 
1 ACCEPTED SOLUTION
Mikelytics
Resident Rockstar
Resident Rockstar

HI @Leigh_G ,

 

Please try the following formula which gives you the number of the last date. I tried it with the following data set.

picture_2.PNG

 (my table name was t_7)

 

 

SUM_SALES_LAST_MONTH =
CALCULATE(
Sum(t_7[Sales]),
FILTER(t_7,t_7[Date]=MAX(t_7[Date])
)
)
 
P.S. The formula name SALES_LAST_DATE would fit better to what it does 🙂 but in the end this is what should work for what you requested.
 
Best regards
Mikelytics
 
Did I solve your request? Please mark my post as solution.
 
Appreciate your Kudos.
------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

View solution in original post

1 REPLY 1
Mikelytics
Resident Rockstar
Resident Rockstar

HI @Leigh_G ,

 

Please try the following formula which gives you the number of the last date. I tried it with the following data set.

picture_2.PNG

 (my table name was t_7)

 

 

SUM_SALES_LAST_MONTH =
CALCULATE(
Sum(t_7[Sales]),
FILTER(t_7,t_7[Date]=MAX(t_7[Date])
)
)
 
P.S. The formula name SALES_LAST_DATE would fit better to what it does 🙂 but in the end this is what should work for what you requested.
 
Best regards
Mikelytics
 
Did I solve your request? Please mark my post as solution.
 
Appreciate your Kudos.
------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.