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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
047
Frequent Visitor

Choose aggregation function dynamically

Hi

 

For measurement 'X', my table already has aggregated data which is aggregated using pandas before being imported into power BI. For example:

 

ProductCountryX_MeanX_90Percentile
ABCAustralia6500070000


There're mulitple visuals on the page all shaowing data based on X_mean, e.g. a filled map which colour codes the countries according to the values of X_mean. Is it possible to let the user choose the aggregation function (pre-calculated in this case), i.e. the user can choose to switch between report showing X_mean & report showing X_90th_percentile? Thanks

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

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.

View solution in original post

6 REPLIES 6
v-jingzhang
Community Support
Community Support

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.

Thanks for the answer. Reading about it, seems to do the job that I need. However, I'm using RS desktop version. I don't think this will be available anytime soon for the RS version since preview features are disabled.

I will mark this as the answer to help anyone else looking for the answer though. Will look into this once it's available as a general feature. Thanks

Hi @047 

 

You can try the solution in this blog: Change the Column or Measure Value in a Power BI Visual by Selection of the Slicer: Parameter Table .... Before the field parameters appear, we all use the solution introduced in the blog to deal with this scenario. 

 

Best Regards,
Community Support Team _ Jing

047
Frequent Visitor

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:

 

CountrySales_avgSales_medianSales_Total
    
    

 

Thanks

Hi @047 ,

 

In my case I have a disconnected table for type of calculation and then I use this to create a dynamic measure which calculates dynamically the calculation and displays on the visual based on the selection in the slicer.

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Pragati11
Super User
Super User

Hello @047 ,

 

Are you looking for something like this?

v2.gif

Here when SUM is selected, chart shows summation of values and so on.

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.