Forum Discussion
Filter out values from Measure Iteration
- Anonymous6 years ago
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
Reread your post. Instead of iterate over Program Name, inside the Values() of my proposed measure try the Cat column instead.
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
mahoneypat you did get me a step closer! So this might work. If I take the Category out of the visual, it does properly average the valid values! So, now I'm into the space of why does the measure work in one context and not another. I haven't previously gotten to even work when the visual was simplified.
- Anonymous6 years agoNot applicableYou are struggling because your model is... well, bad. If you reshape it so that it meets the rules of correct dimensional modelling, your measure will be very simple to write and fast. Currently, the model is simply non-workable.
Here is something about good models in PBI:
https://www.youtube.com/watch?v=_quTwyvDfG0
https://www.youtube.com/watch?v=78d6mwR8GtA
Best
D- Anonymous6 years agoNot applicable
Anonymous I think it is pretty unfair to tell me that my model is bad when I've only shared a very small part and I'm dealing with a somewhat complex problem. If you'd care to let me know what part you think is bad, I'd be happy to further articulate what is driving the decisions I'm making and have made.
The ultimate goal here is to flag dependent categories whose percentage of growth is not within a range based on the average of the growth of the independent categories. Meanwhile everything has to be done as running grand totals as the user could enter multiple projects over a 25 year time horizon and they want to see the impacts of their decisions around the size of those projects across each of their sites. Meanwhile there are existing benchmarkr over that 25 year time horizon that the proposed changes need to be compared against and lastly there are no fixed ratios or relationships between the categories of space, rather the point is to do comparitative analysis of possible decisions to determine their feasilibility. Furthermore the whole data source has to be contained within what amounts to a structured excel file and the users have to be able to enter or manipulate the data with relative ease within Excel. Could I further normalize "projects" possibly, but I don't think that would make a difference here, the other columns are also normalized. Should this be done in a full SQL database with straight-up application development, quite possilbe. The simple fact is my mandate is to provide the end users a great deal of flexibility using Excel and PowerBI. I'd be happy to spend an hour or more on Zoom with your taking you through the whole model if you want to offer free consulting services.
- Anonymous6 years agoNot applicableGood dimensional models consist of facts and dimensions. What you have shown so far does not adhere to this.
You are mixing many different entities in one table. This is BAD and there's nothing more to say. Hence your DAX is not easy to write.
Please watch the vids I've given you links to.
Best
D