Forum Discussion

holywasabi's avatar
holywasabi
Frequent Visitor
2 years ago
Solved

Age bracket : Conditional Formatting not working

Hi all, a helpless newbie here.

I want to create a measure (not calculated column) that : 

  • categorises a customer according to their age when they sign up
  • This is what I hope to achieve

     

I've created a supporting table - Age Group [as shown in the image below], with a min and max value.

 

 

I am getting errors for my DAX code  : 

 

Customer Age (Sort : Sign-up date) =
IF(
    [Customer Age (Based on year signed-up)] <= MAX(  'Age Group'[Max]  )
    &&
    [Customer Age (Based on year signed-up)] >= MAX(  'Age Group'[Min]  ),
    VALUES( 'Age Group'[Age Group] ),
    BLANK()
)

Appreciate any pointers, thanks! ğŸ˜Š
  • holywasabi , Try using below dax

     

    Customer Age Group =
    VAR CustomerAge = [Customer Age (Based on year signed-up)]
    RETURN
    CALCULATE(
    VALUES('Age Group'[Age Group]),
    FILTER(
    'Age Group',
    CustomerAge >= 'Age Group'[Min] &&
    CustomerAge <= 'Age Group'[Max]
    )
    )

2 Replies

  • holywasabi , Try using below dax

     

    Customer Age Group =
    VAR CustomerAge = [Customer Age (Based on year signed-up)]
    RETURN
    CALCULATE(
    VALUES('Age Group'[Age Group]),
    FILTER(
    'Age Group',
    CustomerAge >= 'Age Group'[Min] &&
    CustomerAge <= 'Age Group'[Max]
    )
    )