Forum Discussion

Sushant_Uniphor's avatar
Sushant_Uniphor
Regular Visitor
5 years ago
Solved

Customised Bins for Age Field

Hi All,

 

I would need a help to know how i can make bins as per my choice in power bi.

 

So I have [Age] field, and it has values from diff age groups varies from 15 yrs to 70 yrs.

 

I want to see which age group is using my product more or have most no of footfall in my app.

 

this code is not working for me

 

Bins_NewUser = var temp= COUNT('Tableau_vw_TotalUsers'[Age]) return
if(temp <=10,"less than 10",if(AND(temp>10,temp<=20),"more than 10 and less than 20",if(AND(temp>30,temp<=50),"more than 30 and less than 50","more than 50")))

 

Below is a demo of that...


 

 

 

 

 

 

 

 

 

 

 

 

  • Hi Sushant_Uniphor ,

     

    Are you trying to create a column to use on the X axis? based on the age in the Tableau_vw_TotalUsers table?

    If so you can create a calc column like the following:

     

    User Bin = 
    switch(true(),
    'Tableau_vw_TotalUsers'[Age] <=10, "less than 10",
    'Tableau_vw_TotalUsers'[Age] <=20, "between 10 and 20",
    ....,
    "greater_than_n"
    )

     

    Hope that Helps

  • Anonymous's avatar
    Anonymous
    5 years ago

    You can achieve it by creating a conditional column for the ranges and then using that field on the chart. 

    Go to Power Query > Add Column > Conditional Column and type the following conditions:

    I used a random sample from Excel. Find my work files on the following Drive folder.

3 Replies

  • richbenmintz's avatar
    richbenmintz
    Icon for Resident Rockstar rankResident Rockstar

    Hi Sushant_Uniphor ,

     

    Are you trying to create a column to use on the X axis? based on the age in the Tableau_vw_TotalUsers table?

    If so you can create a calc column like the following:

     

    User Bin = 
    switch(true(),
    'Tableau_vw_TotalUsers'[Age] <=10, "less than 10",
    'Tableau_vw_TotalUsers'[Age] <=20, "between 10 and 20",
    ....,
    "greater_than_n"
    )

     

    Hope that Helps

  • Anonymous's avatar
    Anonymous
    Not applicable

    You can achieve it by creating a conditional column for the ranges and then using that field on the chart. 

    Go to Power Query > Add Column > Conditional Column and type the following conditions:

    I used a random sample from Excel. Find my work files on the following Drive folder.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Sushant_Uniphor,

    Did these suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements to find it more quickly.

    If these also not help, please share more detailed information to help us clarify your scenario to test.

    How to Get Your Question Answered Quickly 

    Regards,

    Xiaoxin Sheng