Forum Discussion

inglexjc's avatar
inglexjc
Post Patron
3 years ago
Solved

Creating Range for Age Groups

I need to create a graph to show age groups, and have them color coded based on age and date they have court.

 

My table that has data has PPI so I can't share it.  But the table name is called "Legal Files" and I have Child DOB and Age as columns (in addition to Court Date and other information not needed for this graph).

 

Please advise how to group these ages and then how to color code these age groups.

  • hi inglexjc ,

     create a table as follows:

     

    table code: 

    let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDBONlTSUQJhAxDWs4QDpVidaCVDXVOgsBFUiQm6tKmuIUibMRCD1FliaDfQBmkDaTcAEwigFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Band = _t, Order = _t, Min = _t, Max = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Band", type text}, {"Order", Int64.Type}, {"Min", Int64.Type}, {"Max", type number}})
    in
    #"Changed Type"

    ______

     

    create a measure:

     

    Count Age = 
    VAR __AgeBandMin = SELECTEDVALUE('Table'[Min] ) 
    VAR __AgeBandMax = SELECTEDVALUE('Table'[Max] )
    return
    CALCULATE(
        COUNT(Table2[Age]),
        Legal Files[Age] >= __AgeBandMin,
        Legal Files[Age] <= __AgeBandMax 
    )

     

     

    Appreciate a thumbs up if this helped.

     

    Please accept this as the solution if your query is resolved.

     

10 Replies

  • adudani's avatar
    adudani
    Memorable Member

    hi inglexjc ,

     create a table as follows:

     

    table code: 

    let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wiik1MDBONlTSUQJhAxDWs4QDpVidaCVDXVOgsBFUiQm6tKmuIUibMRCD1FliaDfQBmkDaTcAEwigFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Band = _t, Order = _t, Min = _t, Max = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Band", type text}, {"Order", Int64.Type}, {"Min", Int64.Type}, {"Max", type number}})
    in
    #"Changed Type"

    ______

     

    create a measure:

     

    Count Age = 
    VAR __AgeBandMin = SELECTEDVALUE('Table'[Min] ) 
    VAR __AgeBandMax = SELECTEDVALUE('Table'[Max] )
    return
    CALCULATE(
        COUNT(Table2[Age]),
        Legal Files[Age] >= __AgeBandMin,
        Legal Files[Age] <= __AgeBandMax 
    )

     

     

    Appreciate a thumbs up if this helped.

     

    Please accept this as the solution if your query is resolved.

     

    • inglexjc's avatar
      inglexjc
      Post Patron

      adudani  I'm sure I'm doing something wrong.  I put in what you gave to create Table:

       

      Got an error so then I tried to change things to Legal Files. Age and I'm still getting an error when creating a table.

       

      • adudani's avatar
        adudani
        Memorable Member

        for the table code:

         

        please go to the power query editor.

        find blank query:

         

         

        in the advanced editor, 

         

        copy paste the table and then hit close and apply at the top left.

         

        then create the measure

    • inglexjc's avatar
      inglexjc
      Post Patron

      adudani I'm still getting an error: "Expression.Syntax.Error: Token Comma expected."

       

       

      • adudani's avatar
        adudani
        Memorable Member

        delete the last 2 lines. ( in and Source)

         

  • Creating clear age ranges really helps bring structure and fairness to any system that categorizes people or data. When ranges are thoughtfully defined, it becomes much easier to analyze trends, compare outcomes, and ensure consistency across different scenarios. I’ve seen similar principles applied effectively in record organization, especially when reviewing Durham Court Cases alongside demographic details. Overall, a well-planned range framework makes information more accessible and decision-making more reliable.

  • I really appreciate how this post highlights the importance of setting clear ranges for age groups, as it improves clarity and consistency in planning and analysis. A similar structured approach is useful when reviewing public information, and I’ve seen this work well with Seminole County Cases because details are organized in an easy-to-follow way. Overall, thoughtful grouping helps people understand data faster and make better decisions.