Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi all,
I have a table in my Dataset that has:
There are other columns that come from the query but I don't need those. It looks like this (I've filtered it down to only two locations for ease of screenshotting):
What I'm having a problem with is filtering the following down to the first non-blank value:
I managed at one point to return the date of the first non-blank value, but I got stumped there and couldn't do anything else. I even tried to use the Measure that returned the date to filter but I couldn't get that to work either.
I found an article online which seems to do what I want, and wrote the following:
Latest_Rate_Per_100k_Rolling =
VAR LastNonBlankDate =
CALCULATE (
LASTNONBLANK ( LTLA[date], 1 ),
FILTER (
ALL ( LTLA ),
LTLA[date] <= EARLIER ( LTLA[date] )
&& NOT ( ISBLANK ( LTLA[Rate per 100k (last 7 days rolling)] ) )
)
)
RETURN
CALCULATE (
SUM ( LTLA[Rate per 100k (last 7 days rolling)] ),
FILTER ( ALL ( LTLA ), LTLA[date] = LastNonBlankDate )
)But this gives me the error:
EARLIER/EARLIEST refers to an earlier row context which doesn't exist.Any ideas on how to do this?
Solved! Go to Solution.
Hi @oliverwebb,
You can try to use the following measure format to get the last value and return tags, then you can use it on 'visual level filter' to filter records based on tags:
Latest Rate_Per_100k_Rolling =
VAR currDate =
MAX ( LTLA[date] )
VAR _lastDate =
CALCULATE (
MAX ( LTLA[date] ),
FILTER (
ALLSELECTED ( LTLA ),
LTLA[date] <= currDate
&& LTLA[Rate per 100k (last 7 days rolling)] > 0
),
VALUES ( LTLA[AreaCode] )
)
VAR lastValue =
CALCULATE (
MAX ( LTLA[Rate per 100k (last 7 days rolling)] ),
FILTER ( ALLSELECTED ( LTLA ), LTLA[date] = _lastDate ),
VALUES ( LTLA[AreaCode] )
)
RETURN
IF ( MAX ( LTLA[Rate per 100k (last 7 days rolling)] ) = lastValue, "Y", "N" )
Applying a measure filter in Power BI - SQLBI
Regards,
Xiaoxin Sheng
@oliverwebb , if this measure use max
Latest_Rate_Per_100k_Rolling =
VAR LastNonBlankDate =
CALCULATE (
LASTNONBLANK ( LTLA[date], 1 ),
FILTER (
ALL ( LTLA ),
LTLA[date] <= MAX( LTLA[date] )
&& NOT ( ISBLANK ( LTLA[Rate per 100k (last 7 days rolling)] ) )
)
)
RETURN
CALCULATE (
SUM ( LTLA[Rate per 100k (last 7 days rolling)] ),
FILTER ( ALL ( LTLA ), LTLA[date] = LastNonBlankDate )
)
Also, check if lastnonblankvalue can helphttps://www.linkedin.com/pulse/five-recent-power-bi-functions-you-should-use-more-often-amit-chandak
This doesn't seem to work - it returns 637679.5 but if I check the table it should be 1195.7 for the latest record.
Hi @oliverwebb,
You can try to use the following measure format to get the last value and return tags, then you can use it on 'visual level filter' to filter records based on tags:
Latest Rate_Per_100k_Rolling =
VAR currDate =
MAX ( LTLA[date] )
VAR _lastDate =
CALCULATE (
MAX ( LTLA[date] ),
FILTER (
ALLSELECTED ( LTLA ),
LTLA[date] <= currDate
&& LTLA[Rate per 100k (last 7 days rolling)] > 0
),
VALUES ( LTLA[AreaCode] )
)
VAR lastValue =
CALCULATE (
MAX ( LTLA[Rate per 100k (last 7 days rolling)] ),
FILTER ( ALLSELECTED ( LTLA ), LTLA[date] = _lastDate ),
VALUES ( LTLA[AreaCode] )
)
RETURN
IF ( MAX ( LTLA[Rate per 100k (last 7 days rolling)] ) = lastValue, "Y", "N" )
Applying a measure filter in Power BI - SQLBI
Regards,
Xiaoxin Sheng
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 9 | |
| 6 | |
| 6 |
| User | Count |
|---|---|
| 26 | |
| 22 | |
| 19 | |
| 17 | |
| 10 |