pivot with sum
I'm trying to pivot if a column is true and I want a sum of all the count where that column is true. Example:
year month group members na_group asia_group
2015 12 US 350 true false
2015 12 MEX 150 true false
2015 12 APAC 250 false true
2015 12 JPN 450 false true
2015 11 US 300 true false
2015 11 MEX 100 true false
2015 11 APAC 200 false true
2015 11 JPN 400 false true
So I want to pivot and have columns
year, month, na_group_total_members, asia_group_total_members, global_total_members
2015, 12, 500, 700, 1200
2015, 11, 400, 600, 1000
-
Official comment
I would accomplish this particular use case using a GROUPBY and GROUPSUM function with a conditional statement to sum the members value if na_group is true or 0 if it is false:
GROUPBY(#MySheet!year)
GROUPBY(#MySheet!month)
GROUPSUM(IF(#MySheet!na_group;#MySheet!members;0))
GROUPSUM(IF(#MySheet!asia_group;#MySheet!members;0))For the global_total_members, I would just add the partial columns together: i.e. #C + #D
Comment actions
Please sign in to leave a comment.
Comments
2 comments