Forum Discussion

naiconn1981's avatar
naiconn1981
Regular Visitor
8 years ago
Solved

Newb Question on table ranging

Hi

 

I'm completely new to Power BI and have been playing around with it, but having trouble grouping specific data.  

 

I like to create a table where I can group specific age range.  For example, I would like to see under Sony what is a range of player's age between 10-18, 19-27, 28-36, 37-42 and 43+.  Is there a formula to do this under Measure?  

 

Below is a table I'm using as a test. 

 

Thank you in advance for anyone who can help!

 

ConsoleCountiesPlayer's Age
SonyBedfordshire12
SonyBerkshire13
SonyBristol25
SonyBuckinghamshire36
SonyCambridgeshire44
SonyCheshire50
SonyCity of London22
SonyCornwall19
SonyCounty Durham18
SonyCumbria16
XboxBedfordshire26
XboxBerkshire22
XboxBristol19
XboxBuckinghamshire13
XboxCambridgeshire32
XboxCheshire34
XboxCity of London40
XboxCornwall38
XboxCounty Durham37
XboxCumbria51
SwitchBedfordshire24
SwitchBerkshire27
SwitchBristol31
SwitchBuckinghamshire16
SwitchCambridgeshire17
SwitchCheshire36
SwitchCity of London35
SwitchCornwall35
SwitchCounty Durham25
SwitchCumbria24
  • Hi naiconn1981,

     

    We can create the measures as below.

     

    Sony 10-18 = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1),Table1[Console]="Sony" && Table1[Player's Age]>=10 && Table1[Player's Age]<=18))
    Sony 19-27 = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1),Table1[Console]="Sony" && Table1[Player's Age]>=19 && Table1[Player's Age]<=27))
    Sony 28-36 = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1),Table1[Console]="Sony" && Table1[Player's Age]>=28 && Table1[Player's Age]<=36))
    Sony 37-42 = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1),Table1[Console]="Sony" && Table1[Player's Age]>=37 && Table1[Player's Age]<=42))
    Sony 43+ = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1),Table1[Console]="Sony" && Table1[Player's Age]>=43))

     

    For more details, please check the pbix as attached.

     

    https://www.dropbox.com/s/hd56qny81bc8232/Newb%20Question%20on%20table%20rangin.pbix?dl=0

     

    Regards,

    Frank

3 Replies

  • v-frfei-msft's avatar
    v-frfei-msft
    Community Support

    Hi naiconn1981,

     

    We can create the measures as below.

     

    Sony 10-18 = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1),Table1[Console]="Sony" && Table1[Player's Age]>=10 && Table1[Player's Age]<=18))
    Sony 19-27 = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1),Table1[Console]="Sony" && Table1[Player's Age]>=19 && Table1[Player's Age]<=27))
    Sony 28-36 = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1),Table1[Console]="Sony" && Table1[Player's Age]>=28 && Table1[Player's Age]<=36))
    Sony 37-42 = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1),Table1[Console]="Sony" && Table1[Player's Age]>=37 && Table1[Player's Age]<=42))
    Sony 43+ = CALCULATE(COUNTROWS(Table1),FILTER(ALL(Table1),Table1[Console]="Sony" && Table1[Player's Age]>=43))

     

    For more details, please check the pbix as attached.

     

    https://www.dropbox.com/s/hd56qny81bc8232/Newb%20Question%20on%20table%20rangin.pbix?dl=0

     

    Regards,

    Frank

    • naiconn1981's avatar
      naiconn1981
      Regular Visitor

      v-frfei-msft thanks Frank.  I will try this.  I was hoping to consign them under a bar chart but guess I can do something similar using the formulas.  

      • v-frfei-msft's avatar
        v-frfei-msft
        Community Support

        Hi naiconn1981,

         

        Has your problem been solved, if any other question, feel free to let me know.

         

        Regards,

        Frank