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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.