Forum Discussion

inglexjc's avatar
inglexjc
Post Patron
1 year ago
Solved

Age Bins

I've created an Age Bin but it's not working correctly.  Code I'm using is:   Age Bins = SWITCH(TRUE(),'Legal Files'[Child Age]=BLANK(),"0",'Legal Files'[Child Age]<=1, "<1",'Legal Files'[Child Age...
  • danextian's avatar
    1 year ago

    As per your condition, Age 0 is <1 as you used <=1 instead of <1.  Also, shouldn't it be 6-10 instead of 5-10 as there is already a category that includes 5?

     

    Age Bins =
    SWITCH (
        TRUE (),
        ISBLANK ( 'Legal Files'[Child Age] )
            || 'Legal Files'[Child Age] = 0, "0",
        'Legal Files'[Child Age] < 1, "<1",
        'Legal Files'[Child Age] <= 5, "1-5",
        'Legal Files'[Child Age] <= 10, "6-10",
        'Legal Files'[Child Age] > 10, "Older than 10"
    )
    

     

     

  • FBergamaschi's avatar
    FBergamaschi
    1 year ago

    Hi inglexjc,

    using the filw that v-hjannapu attached, I see this if I turn the graph into a  table visual

     

     

    Age 0 is included and considered and all the children (7 rows) are shown

     

    If you still have issues, the only way to fix it is that you share some of your data so we check if there is any anomaly. Please anyway make sure to check the result as a table visual and only after as a graph

     

    If you have already done this and I missed the thing, apologies, just please send here the link to your data. We need to fix the thing on your semantic model in my opinion

     

    If this helped, please consider giving kudos and mark as a solution

    @me in replies or I'll lose your thread

    Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

    Consider voting this Power BI idea

    Francesco Bergamaschi

    MBA, M.Eng, M.Econ, Professor of BI