Forum Discussion
Choose aggregation function dynamically
- 4 years ago
Hi 047
The new preview feature Field parameters is probably what you want. Since your data is pre-calculated in different columns, you just need to select data from different columns when switching the choices. You can create separate measures like below to get values from single columns. Then create a field parameter and add these measures to the parameter. Use the field parameter in your visual to switch the aggregations.
Mean value = SELECTEDVALUE('Table'[X_Mean])90Percentile Value = SELECTEDVALUE('Table'[X_90Percentile])Other reference: How to dynamically switch between measures in Power BI visuals with Field Parameters
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hi
Thanks for the reply. I'm not sure if the example you showed has the data precalculated, so makes the calculation on the fly when selecting the Calc type in the slicer. Just to clarify, in my case, power BI doesn't have access to the raw data (with hundreds of thousands of rows). The data is already aggregated. Taking your example, the avg, median & sum of Sales by country are pre-calculated in different columns...something like this:
| Country | Sales_avg | Sales_median | Sales_Total |
Thanks