0

How to display a groupby function on an if statement for a barchart?

Dear community, 

I am trying to build a barchart with a series for each type of user. Which are the following:

  • Investor
  • Creator
  • Administrator 

And I want to count those by region. Which are the following:

  • Center region
  • North region 
  • East region
  • NULL region 

For my X-axis I am doing the following to display by region:

GROUP(@Region)

For my series I am doing the following:

GROUPBY(@Region;@UserType="Creator",count)


I expect for this series to only count where the user type is Creator. Nonetheless, the output is the count of all users despite the rule.

How can I do this in a different way so it works? 

3 comments

  • 0
    Avatar
    Meggan King

    Hello

    Thank you for reaching out to the community. 

    Based on your example, your data would not work because in GROUPBY you have two different groups of data. @region would be all the data and @userType would be a subset of data based on your condition. This will not group correctly. In this case you will want to select the same amount of data

    GROUPBY(Select(Region,(UserType="Creator")),Select(UserType,(UserType="Creator)),count)

    https://support.klipfolio.com/hc/en-us/articles/215547998-GROUP-GROUPBY-and-COUNTDISTINCT-video-

    Hope this helps,

    Meggan

  • 0
    Avatar
    Zhanna Orlova

    Hi Meggan, 

    Thank you so much for following up on my question. I still don't get the data. Would you be so kind to specify which information goes on the xaxis and which goes in the series? 

  • 0
    Avatar
    Meggan King

    Hi Zhanna

    Based on your general question you need 

    GROUP(@Region) on your xaxis

    Each series will have the unique GROUPBY.

    The last piece is the LOOKUP or IF to align the data to your xaxis. 

    You can use IF to align and then use Applied Actions or LOOKUP with your GROUP/GROUPBY on each series. It depends on what your data is like. 

    However there are many ways to do this so it will be best to open a support ticket for your specific Klip. You can open a ticket on here or send email to support @ klipfolio. com

    Thank you

    Meggan

     

Please sign in to leave a comment.