Forum Discussion
JDLee23
9 years agoHelper I
Calculate an average based on an implicit filter by a second column
Hi, I am trying to create a measure which will allow me to show an average, based on the selection in a slicer. However, the slicer only implicitly selects the group of data, for example - In...
- 9 years ago
Hi JDLee23,
Thanks for TomMartens's suggestion, it works fine in my test. But, it is not able to directly define a column name for variable, so, I made some modification:
Avg Sales Country = var currentCountry = LASTNONBLANK('table'[Country],1) return CALCULATE( AVERAGE('table'[TotSales]) ,ALL('table'[City]) ,'table'[Country] = currentCountry )Best regards,
Yuliana Gu
v-yulgu-msft
9 years agoMicrosoft Employee
Hi JDLee23,
Thanks for TomMartens's suggestion, it works fine in my test. But, it is not able to directly define a column name for variable, so, I made some modification:
Avg Sales Country =
var currentCountry = LASTNONBLANK('table'[Country],1)
return
CALCULATE(
AVERAGE('table'[TotSales])
,ALL('table'[City])
,'table'[Country] = currentCountry
)
Best regards,
Yuliana Gu
- TomMartens9 years agoSuper User
- JDLee239 years agoHelper I
v-yulgu-msft, TomMartens - thanks very much for your help, much appreciated!