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
Anonymous
Not applicable

Filter out values from Measure Iteration

I have a measure that is almost working... I'm stuck on not being able to filter out values that don't match certain criteria.

 

I'll outline the logic first, then post my current measure:

  1. For a given site
  2. For a specific project
  3. Where CareServices = True
  4. And Gross Program > 0
  5. AVERAGEX [% of Program Category]

Measure LogicMeasure Logic

 

As you can see, where the context strictly meets the criteria (Project 2) the measure currently works, but where the criteria are not strictly met, I don't get the "correct" answer.

 

Here is the current measure:

% Cat Avg = 
CALCULATE(
AVERAGEX(
prog_SiteAll,
[% of Program Category]
),
ALLEXCEPT(prog_SiteAll, site_Sites[Abbreviated Name], prog_SiteAll[Project Name]),
FILTER(prog_SiteAll, prog_SiteAll[Gross Program Area] > 0) // I don't think this line is currently doing much, if anything... at least nothing useful.
)

Thanks very much for looking! Spent serveral hours today watching videos and trying to better wrap my head around Evaluations and Filter Contexts particularly when you're in a measure, and I'm stuck!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@mahoneypat thanks for trying to assist and being friendly about it! Since it needed it anyhow I did rebuild the data model and made a few small tweaks. I think though it should've still been able to work in the old data model. The final Measure looks like this, the use of "Values" was the keystone, ironically tripped myslef up on the conditional operators when manually cross checking the mathematical results (oh well):

 

Avg Cat Deviation Value = 
VAR __Calc = //create a virtual table that filters to the context of the current row; Site, Project, and associate Space Categories that are Care Services. Include the caluclated measures for the % of Benchmark Program and the previous % of Benchmark Program
CALCULATETABLE(
ADDCOLUMNS(
SUMMARIZE( 'prog Proposed Project Program', Sites[Abbreviated Name], 'prog Projects'[ID], 'prog Space Categories'[ID] ),
"% of Bnch", [Program % of Cat Benchmark Prog], "Prev %", [Prev % Bnch]
),
ALL('prog Proposed Project Program'), //get all rows from this table
VALUES(Sites[Abbreviated Name]), //filter to the Site context of current row
VALUES('prog Projects'[Project Name]), //filter to the Project context of current row
'prog Proposed Project Program'[Program Area] > 0, //filter for only categories that have changed in this project
'prog Space Categories'[CareServices] = TRUE() // filter for Space Categories that are only marked as "Care Services"
)

VAR AVGBnch = AVERAGEX( __Calc, [% of Bnch]) //calculate the Average of the rows in the filtered table
VAR AVGPrev = AVERAGEX( __Calc, [Prev %]) //calculate the Average of the rows in the filtered table
VAR PercRemainder = (AVGBnch - AVGPrev)
RETURN
PercRemainder

 

View solution in original post

12 REPLIES 12

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.

Top Solution Authors