cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
MickyG
Frequent Visitor

Create a Measure to retrieve most recent value on a matrix

I am creating a visual matrix w/ the columns stated below. The first 3 columns are being calculated by counting the data records we have, however the "County Cases per 100k" is being uploaded from public records. The county data has a 7 day average for each day. The problem is that the previous 3 columns calculate there data in between the date ranges (8/22-8/28) in the slicer, but for the last column, I only need the value from the last date (8/28). I tried creating a measure to LOOKUPVALUE() from the "County Cases per 100k" column using my HelperColumn, but because there are several records from each location it returns  either an avg, min, or max etc. of all of the county 7 day averages. I only need the most recent value based on the filter date.

 

Date Slicer: 8/22/21 - 8/28/21

-Campus-Campus Enrollment-Campus Cases-Campus Avg. per 100k -County Cases per 100k (7 Day)
Location1    
Location2    
Location3    
Location4    

 

Measure for last column:

County Cases Average per 100k = LOOKUPVALUE('County COVID Data'[cases_avg_per_100k],'County COVID Data'[HelperColumn],'Campus Case Master'[HelperColumn])
 
Note: I've also tried an extra search value (see below) to try and only get the value for the most recent date but it would populate todays date instead of the most recent date in the matrix (based on date slicer).

 

County Cases Average per 100k = LOOKUPVALUE('County COVID Data'[cases_avg_per_100k], 'County COVID Data'[HelperColumn], 'Campus Case Master'[HelperColumn], 'County COVID Data'[Date], MAX('Campus Case Master'[Date]))

2 REPLIES 2
selimovd
Super User
Super User

Hey @MickyG ,

 

it's a little bit hard to tell without knowing the data model. I don't really see a need for a lookup.

Can you check if the following approach works:

County Cases Average per 100k =
CALCULATE(
    SUM( 'County COVID Data'[cases_avg_per_100k] ),
    'County COVID Data'[Date] = MAX( 'Campus Case Master'[Date] )
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

The "Campus Case Master' and 'County COVID Data' are both linked by the HelperColumn. I've tried using the date as a link as well and get the same results. Also, I tried the formula you sent. The error I recieve is "A function MAX has been used in a True/False expression that is used as a table filter expression. This is not allowed."

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors