Forum Discussion
Alternative Approaches To Referencing Calculated Measure in a Calculated Column?
Hi Power BI Community!
Goal: To be able to identify outlier values from the dataset dynamically and have them highlighted in the table.
Approach:
- I have created a calculated measure 'MTTCA_UpperFence_TEST' for a specific metric that dynamically calculates the outlier threshold and returns that value. <-- This is working
- Created a calculated column in the 'FUN_MTT_measures' table called 'REF_IsOutlier?' This column would have a string value of either 'Outlier' or 'Not Outlier' based on the calculation of is the MetricValue > MTTCA_UpperFence_TEST. <-- Not Working
Problem: When I slice the data, the measure returns the correct outlier threshold. However the 'REF_IsOutlier?' column doesn't seem to recognize the newly updated value returned from measure and instead is calculating based on the outlier value that's calculated for the whole dataset instead of the subset of it.
Research: I've spent quite a bit of time on the Power BI forums researching and also Googling in general to see what might the issue. It seems the consensus is that tables and calculated columns are only "computed during database processing(e.g. data refresh) and then stored in the model, they do not response to user selections on the report(like a Slicer)."
Source: https://community.powerbi.com/t5/Desktop/New-table-with-measures-values/td-p/189124
I have a dataset 'FUN_MTT_measures' that has the following fields:
- Date : Date
- LocalID : Int
- AreaPathExtractDAD: String
- MetricName : String
- MetricValue : Long
Created calculated measure 'MTTCA_UpperFence_TEST' <-- This works
MTTCA_UpperFence_TEST = // Calculating the upper boundary for MTTCA // Data used from FUN_MTT_measures VAR MTTCA_UpperQuartile = CALCULATE(PERCENTILE.INC(FUN_MTT_measures[MetricValue], 0.75), ALLSELECTED(FUN_MTT_measures), FUN_MTT_measures[MetricName] = "mttca") // Calculating upper quartile VAR MTTCA_LowerQuartile = CALCULATE(PERCENTILE.INC(FUN_MTT_measures[MetricValue], 0.25), ALLSELECTED(FUN_MTT_measures), FUN_MTT_measures[MetricName] = "mttca") // Calculating lower quartile VAR MTTCA_IQR = MTTCA_UpperQuartile - MTTCA_LowerQuartile // Calculating inter quartile RETURN (MTTCA_UpperQuartile + 1.5 * MTTCA_IQR) // Return upper boundary for MTTCA
Created calculated column 'REF_IsOutlier' in the 'FUN_MTT_measures' tables <-- This doesn't work
REF_IsOutlier = SWITCH(TRUE(), // [Calculated Column] Returns either "Outlier" or "Not Outlier" depending on the current Metric Value compared to the corresponding upper boundary of the selected metric. This field can be used to filter the table between outlier and non-outlier data. AND(FUN_MTT_measures[MetricName] = "mttrs", FUN_MTT_measures[MetricValue] > [MTTRS_UpperFence_TEST]), "Outlier", // Checks to see if MTTRS' metric value is an outlier. If yes, returns "Outlier" text. AND(FUN_MTT_measures[MetricName] = "mttca", FUN_MTT_measures[MetricValue] > [MTTCA_UpperFence_TEST]), "Outlier", // Checks to see if MTTCA's metric value is an outlier. If yes, returns "Outlier" text. AND(FUN_MTT_measures[MetricName] = "mttcn", FUN_MTT_measures[MetricValue] > [MTTCN_UpperFence_TEST]), "Outlier", // Checks to see if MTTCN's metric value is an outlier. If yes, returns "Outlier" text. "Not Outlier") // Not an outlier, returns "Not Outlier" text.
I've attempted to do a simple test with an if function but that doesn't seem to work either..
REF_IsOutlier = IF(AND(FUN_MTT_measures[MetricName]="mttca", FUN_MTT_measures[MetricValue] > [MTTCA_UpperFence_TEST]), "Outlier", "Not Outlier")
I was hoping one of you gurus here can provide me some direction or an alternative approach.
Thanks in advance!
-James
I was able to accomplish what I needed by creating a measure for each metric value and a measure for each metric's outlier threshold.
Then I created a measure, using switch to compare the metric value to the threshold and return either "Outlier" if it's above the threshold or "Not Outlier" if it's below or equal to the threshold.
5 Replies
- v-lili6-msftCommunity Support
hi, jimmyswoosh
Calculate table and calculate column all affected by any slicer or other visuals on the report. they are only affected by
the database refresh. So you can't compare measure with column.
The only way is that you create a measure again and then compare them.
Best Regards,
Lin
- jimmyswooshAdvocate I
Thanks v-lili6-msft for the reply,
For clarification on my part, are you saying that there's no way to acheive a workaround solution since we can't compare measure in a column?
-James
- v-lili6-msftCommunity Support
hi, jimmyswoosh
the result of measure is dynamic and the result of column is static, so they can't be compared in together.
It is usually that column and column comparisons or measure and measure comparisons.
Best Regards,
Lin