Thank you for responding. I think you got confused bc of so much information I put in the question. Apologies for that.
I was able to get the average for customers just fine. The issue I’m facing is for the average of % values. In that I want true average but I’m getting weighted average in quicksight.
You can use the same calculated field in both views. When you use it in your 2nd view and remove the topics column from your table, it will give you the correct average.
I tried your approach and am getting “LAC aggregate functions inside one visual aggregate functions should always share the same grouping key” error in both views.
Whether I include topics in the group by or not.
I read through some of your past answers regarding this issue but not relates to my use case… Appreciate your responses here.
Are you not grouping by the topics field in both sums? Is customers_all a calculated field? I didn’t see the calculation for it in your question, so I assumed that it’s not calculated.
It worked for me now. I realized that calculation you provided was correct, the last same grouping key error I was getting is because “Topics” was an if else string manipulation calculation.
Which is very strange, I wasn’t changing anything just adding a key word in the same string… but any way when I used the base topics field in the calculation it worked out.
Since the question is still open, can I ask a quick follow up?
I created the views and calculations work fine, now I’m trying to use the “% values” calculated field as a filter.
say filter only for topics with % values greater than or equal to 50%. The filter works fine for view 1 but filters everything out for the view 2 (the averages one) because the average of % values field is less than 50%
Is there a way I can have this filter that it just filters for topics in view 1 and in view 2 I get the averages of topics left in view 1??
If you want to add a filter, you have to use LAC-W instead of LAC-A. Keep the previous calculated field to show in the visuals but create another one using LAC-W and use it for filtering purposes.
Create a table visual containing the following columns:
topics
customers
customers_all
The calculated field which contains the LAC-W function.
It will help you understand how LAC-W functions work.
You’ll see that the same percentage is displayed in every row that contains the same topic because we used topic as our partition in the sumOver function.
If you select average as aggregation, QuickSight will calculate the average value as (60 + 60 + 31.03 + 31.03 + 31.03)/5 = 42.62 since you’re not grouping by anything in view #2. If you then filter by >= 50, you won’t get anything.
If you don’t select any aggregation and filter by >= 50, it will exclude topic B and your calculation for the percentage will be based on topic A only.