Hi Quick Sight Community,
I’m trying to create a calculated field in Amazon Quick Sight that calculates the average of HouseAge across unique Postalcode values, grouped by Division. I’m running into some trouble and would appreciate any guidance.
Here’s a sample of my dataset:
| `CaseKey | Postalcode | HouseAge | Division |
|---|---|---|---|
| 1 | 650291 | 24 | AG |
| 2 | 650291 | 24 | AG |
| 3 | 650291 | 24 | AG |
| 4 | 650292 | 20 | AG |
| 5 | 650293 | 30 | PD |
| 6 | 650293 | 30 | PD |
| 7 | 650294 | 35 | PD |
| 8 | 650295 | (null) | PD |
| 9 | 650296 | (null) | PD` |
Expected Results per Division:
- AG Division:
- Unique Postal Codes and their average
HouseAge:- 650291: 24
- 650292: 20
- Average of unique postal code averages: (24 + 20) / 2 = 22
- Unique Postal Codes and their average
- PD Division:
- Unique Postal Codes and their average
HouseAge:- 650293: 30
- 650294: 35
- (Postal codes 650295 and 650296 are ignored due to null
HouseAge) - Average of unique postal code averages: (30 + 35) / 2 = 32.5
- Unique Postal Codes and their average
Expected Result:
| CaseKey | Postalcode | HouseAge | Division | AverageDivisionHouseAge |
|---|---|---|---|---|
| 1 | 650291 | 24 | AG | 22 |
| 1 | 650291 | 24 | AG | 22 |
| 1 | 650291 | 24 | AG | 22 |
| 2 | 650291 | 24 | AG | 22 |
| 3 | 650292 | 20 | AG | 22 |
| 4 | 650293 | 30 | PD | 32.5 |
| 4 | 650293 | 30 | PD | 32.5 |
| 5 | 650293 | 30 | PD | 32.5 |
| 6 | 650294 | 35 | PD | 32.5 |
| 7 | 650295 | PD | 32.5 | |
| 8 | 650296 | PD | 32.5 |
I’ve been trying to use a combination of avgOver and potentially some partitioning, but I’m struggling to get the correct level of aggregation.
Could anyone provide guidance on how to create this calculated field in Quick Sight? Any help or suggestions would be greatly appreciated!
@WLS-D @ytakahr @Giridhar.Prabhu @Rahul_Easwar
Thanks in advance,