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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
kamiluc
Helper I
Helper I

Help finding issue in measure

Hi,

I have a table (RISK_EVALUATION) that contains risk evaluations for RISKIDs (can be multiple) along with dates and outcomes. I then created a measure that I intent to include in a matrix to count how many risks have the latest evaluation as "Not Assessed".

 

The matrix will have the last day of the month from a calendar table as columns.  A RISKID should be counted on that month if the latest evaluation, even if done many months ago, had a value of "Not Assessed". It'd look like this:

 Sep-23Oct-23Nov-23Dec-23
# Risks Not Assessed5544

 

My current measure:

 

# Risks Not Assessed =

var _selectdate = MAX(dCalendar[Date])

var tmp =  FILTER( ALL( RISK_EVALUATION), RISK_EVALUATION[RE_DATE] <= _selectdate) --create a temp table with evaluations only up to the date selected
var tmp1 = SUMMARIZE(tmp, [RISKID], "Max Date", MAXX( RISK_EVALUATION, RISK_EVALUATION[RE_DATE])) --create a temp table summarising risk by the latest evaluation date
var tmp2 = SELECTCOLUMNS( ADDCOLUMNS( tmp1, "Concate_Str", [RISKID] & [Max Date]), "Concate_Str", [Concate_Str]) --create a temp table with single column concatenating riskid and mre date
var tmp3 = FILTER( tmp, [RISKID] & [MRE_DATE] IN tmp2) --create temp table based on first tmp, filtering only those with the latest RE date for each risk
var tmp4 = CALCULATETABLE( VALUES( RISK_EVALUATION[RISKID]), FILTER( tmp3, [RE_RATING] = "Not Assessed" )) --create temp table for the risks where the latest RE is defined as not assessed. 

var _a = COUNTROWS(tmp4) + 0
var _risknotassessed = IF( ISBLANK(_a), 0, _a)
 
return
_risknotassessed
 
This however is not giving me the correct output. More specifically, when I apply some filters, the value of the measure is not impacted by the filters when it should.  I've looked at it enough and can't seem to find the issue so hoping the community could help me spot my mistake. Thanks!
1 ACCEPTED SOLUTION
kamiluc
Helper I
Helper I

I have figure it out. My error was on the variable tmp1 which was producing a table with the latest date for all RISKIDs, rather than the latest for each RISKID.

 

I've replaced that variable by the following:

 

var tmp1 = 
SUMMARIZE(
FILTER(
FILTER(RISK_EVALUATION,RISK_EVALUATION[RE_DATE]<=_selectdate),
RISK_EVALUATION[RE_DATE]
= CALCULATE (
MAX ( RISK_EVALUATION[RE_DATE] ),
ALLEXCEPT ( RISK_EVALUATION, RISK_EVALUATION[RISKID] )
)
),[RISKID],[RE_DATE])

 

This actually eliminates the need for the variable tmp as well.

View solution in original post

1 REPLY 1
kamiluc
Helper I
Helper I

I have figure it out. My error was on the variable tmp1 which was producing a table with the latest date for all RISKIDs, rather than the latest for each RISKID.

 

I've replaced that variable by the following:

 

var tmp1 = 
SUMMARIZE(
FILTER(
FILTER(RISK_EVALUATION,RISK_EVALUATION[RE_DATE]<=_selectdate),
RISK_EVALUATION[RE_DATE]
= CALCULATE (
MAX ( RISK_EVALUATION[RE_DATE] ),
ALLEXCEPT ( RISK_EVALUATION, RISK_EVALUATION[RISKID] )
)
),[RISKID],[RE_DATE])

 

This actually eliminates the need for the variable tmp as well.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.