Forum Discussion
Averages by String
- 6 years ago
Hi Anonymous
I have shared a sample PBIX here.
I would recommend you transform your data into this form to make the calculations easier:
Resident ID Path Description PathItem Type Days 1 Apt, Townhome, House 1 Apt 385 1 Apt, Townhome, House 2 Townhome 400 1 Apt, Townhome, House 3 House 600 2 Villa, House 1 Villa 365 2 Villa, House 2 House 500 3 Apt, Townhome, House 1 Apt 400 3 Apt, Townhome, House 2 Townhome 90 3 Apt, Townhome, House 3 House 285 4 Townhome, Villa, House 1 Townhome 200 4 Townhome, Villa, House 2 Villa 160 4 Townhome, Villa, House 3 House 390 5 Apt, Townhome, House 1 Apt 90 5 Apt, Townhome, House 2 Townhome 180 5 Apt, Townhome, House 3 House 400 I have done this in Power Query in the above PBIX.
Then create measures:
Number of Residents = DISTINCTCOUNT ( Residence[Resident ID] ) Average Days = AVERAGE ( Residence[Days] ) Average Days Concatenated = IF ( HASONEVALUE ( Residence[Path Description] ), // ensure just one Path Description is selected CONCATENATEX ( VALUES ( Residence[PathItem] ), ROUND( [Average Days], 0), ", ", Residence[PathItem] ) )After doing this, you can create a table similar to the one you posted:
Anyway that is how I would approach this. Hopefully that's of some use 🙂
Regards,
Owen
Hi Anonymous
I have shared a sample PBIX here.
I would recommend you transform your data into this form to make the calculations easier:
| Resident ID | Path Description | PathItem | Type | Days |
| 1 | Apt, Townhome, House | 1 | Apt | 385 |
| 1 | Apt, Townhome, House | 2 | Townhome | 400 |
| 1 | Apt, Townhome, House | 3 | House | 600 |
| 2 | Villa, House | 1 | Villa | 365 |
| 2 | Villa, House | 2 | House | 500 |
| 3 | Apt, Townhome, House | 1 | Apt | 400 |
| 3 | Apt, Townhome, House | 2 | Townhome | 90 |
| 3 | Apt, Townhome, House | 3 | House | 285 |
| 4 | Townhome, Villa, House | 1 | Townhome | 200 |
| 4 | Townhome, Villa, House | 2 | Villa | 160 |
| 4 | Townhome, Villa, House | 3 | House | 390 |
| 5 | Apt, Townhome, House | 1 | Apt | 90 |
| 5 | Apt, Townhome, House | 2 | Townhome | 180 |
| 5 | Apt, Townhome, House | 3 | House | 400 |
I have done this in Power Query in the above PBIX.
Then create measures:
Number of Residents =
DISTINCTCOUNT ( Residence[Resident ID] )
Average Days =
AVERAGE ( Residence[Days] )
Average Days Concatenated =
IF (
HASONEVALUE ( Residence[Path Description] ), // ensure just one Path Description is selected
CONCATENATEX (
VALUES ( Residence[PathItem] ),
ROUND( [Average Days], 0),
", ",
Residence[PathItem]
)
)
After doing this, you can create a table similar to the one you posted:
Anyway that is how I would approach this. Hopefully that's of some use 🙂
Regards,
Owen
- Anonymous6 years agoNot applicable
Thanks Owen!! This worked perfectly!