Forum Discussion
FILTER used for age classification
Hi,
I am trying to get the below logic to work. The idea is to create an age group for the employees like 30-40, 40-50 etc.
I created an isolated table - Age Group with the groups I need.
Now I need to map the grouping based on the age field in my EMployees table. So I create a Age Group column (new column)
However I am unable to use the column Customer Age column I created. This is all in the Employees table.
Age Group =
CALCULATE (
VALUES ( AgeGroups[Age Group] ),
FILTER (
AgeGroups,
Sales[CustomerAge] >= AgeGroups[Min]
&& Sales[CustomerAge] < AgeGroups[Max]
)
)
Thanks a lot, it worked!!
But I had to make a change, the storage mode was changed to import.
8 Replies
- Ashish_Mathur
Super User
Hi,
This calculated column formula in the Sales table should work
Age Group = CALCULATE(VALUES(AgeGroups[Age Group]),FILTER(AgeGroups,EARLIER(Sales[CustomerAge])>=AgeGroups[Min]&&EARLIER(Sales[CustomerAge])<AgeGroups[Max]))
If it does not work, then share the link from where i can download your PBI file.
Hope this helps.
- PBIfanatic
Helper V
Thanks a lot, it worked!!
But I had to make a change, the storage mode was changed to import.
- Ashish_Mathur
Super User
You are welcome.
- Greg_Deckler
Community Champion
Age Group = MAXX( FILTER('AgeGroups', 'Sales'[CustomerAge] >= 'AgeGroups'[Min] && 'Sales'[CustomerAge] < 'AgeGroups'[Max] ), 'AgeGroups'[Age Group] )- PBIfanatic
Helper V
Hi Greg_Deckler ,
I dont get the option to select
'Sales'[CustomerAge]
I can only choose the measures (from intellisense), the calculated column Customer Age doesnt appear.
- littlemojopuppy
Community Champion
Have you considered using Groups/Binning in Power BI instead of DAX?