Forum Discussion
Mahamood0218
Helper II
3 years agocan not find age buckets
hi,
i am not able to find age Buckets by using if statement ,
could you please suggest from 61 to 90days and >90days.
Thanks.
- age= IF('Date'[age]<=30,"<30days",IF('Date'[age]>=31 && 'Date'[age]<=60,"31 to 60 days",IF('Date'[age]>=61 && 'Date'[age]<=90,"61 to 90 days",IF('Date'[age]>90 ,">90days"))))
- Anonymous3 years ago
try this:
Bucket =SWITCH(TRUE(),Days[Days]<30,"<30days",Days[Days]<60,"30 to 60 days",Days[Days]<90,"60 to 90 days",">90days")
6 Replies
- Mahesh0016
Super User
age= IF('Date'[age]<=30,"<30days",IF('Date'[age]>=31 && 'Date'[age]<=60,"31 to 60 days",IF('Date'[age]>=61 && 'Date'[age]<=90,"61 to 90 days",IF('Date'[age]>90 ,">90days")))) - AilleryO
Memorable Member
Hi,
Or you could do the test the other way (starting with biggest numbers), to make it more simple :
age buckets = IF('Date'[age]>90,">90days",
IF('Date'[age]>60,"61 to 90 days",
IF('Date'[age]>30,"31 to 60 days",
IF('Date'[age]<30 ,"<30 days"))))Hope it helps
- Mahesh0016
Super User
AilleryO it is not correct.
- AilleryO
Memorable Member
Hi,
Can you tell us more or provide sample data because it should work, maybe a problem with parenthesis or column name (should be [Days] not [Age] ?)...
age buckets = IF('Table'[Days]>90,">90days",
IF('Table'[Days]>60,"61 to 90 days",
IF('Table'[Days]>30,"31 to 60 days",
IF('Table'[Days]<30 ,"<30 days"))))I'm in a train so cannot make proper test but it should work, if your column is type number.
Let us know
- AnonymousNot applicable
try this:
Bucket =SWITCH(TRUE(),Days[Days]<30,"<30days",Days[Days]<60,"30 to 60 days",Days[Days]<90,"60 to 90 days",">90days") - Mahamood0218
Helper II
thank you all now dax fuction is working