Forum Discussion

stuf1968's avatar
stuf1968
Frequent Visitor
9 years ago
Solved

User table instead of multiple IF for cohort second table.

First, as with many others here - I'm relatively new to PBI and DAX, and my books haven't arrived from Indigo/Chapters yet.  :smileyhappy:   I have created a data table (tAgeCohort) for min/max of ...
  • v-caliao-msft's avatar
    v-caliao-msft
    9 years ago

    Hi stuf1968,

     

    You need to have a consecutive age number in your tAgeCohort, and set age range for this age. Then you can get age range in z_TTL_Mbr table by using age value.

    Create a table with a column ID have values from 1 to 125. Then create three calculated columns.
    AgeRange = if(and(tAgeCohort[ID]<=29,tAgeCohort[ID]>=20),"20-29",if(and(tAgeCohort[ID]<=39,tAgeCohort[ID]>=30),"30-39",if(and(tAgeCohort[ID]<=49,tAgeCohort[ID]>=40),"40-49",if(and(tAgeCohort[ID]<=59,tAgeCohort[ID]>=50),"50-59",if(and(tAgeCohort[ID]<=69,tAgeCohort[ID]>=60),"60-69",if(and(tAgeCohort[ID]<=79,tAgeCohort[ID]>=70),"70-79",if(tAgeCohort[ID]>=80,"80+","UNK")))))))
    Min = CALCULATE(MIN(tAgeCohort[ID]),ALLEXCEPT(tAgeCohort,tAgeCohort[AgeRange]))
    Max = CALCULATE(MAX(tAgeCohort[ID]),ALLEXCEPT(tAgeCohort,tAgeCohort[AgeRange]))

     

    Then create a caluclated column in z_TTL_Mbr table.
    Age Group = LOOKUPVALUE(tAgeCohort[AgeRange],tAgeCohort[ID],z_TTL_Mbr[Age])

    Then you can use this column in your slicer or visual.

     

    Regards,

    Charlie Liao