Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Multiple IF and SWITCH for a calculated column

I want to see the overlap between multiple groups.  The users in each group are working on a site and I need to know which respective groups interracted with each site. 

 

I have user and site columns and want to get a formula in order to calculate the "Wanted" column.  As you may be able to see, I only care for specific groups that touch each site.  I only care about a, b, and d.  This means that I need to track all interactions between:

abd

ab

bd

ad

a

b

d

The goal is to have a pie chart to show the count of real sites broken into the groups that work on them.  I hope to do this while respecting the individuality of each site.

 

 

SiteUserWanted
1aabd
1babd
1aabd
1dabd
2cbd
2bbd
2dbd
3aab
3bab
4aad
4cad
4dad
4ead
5aa
5ca
5ea

 

Here is another example that is also acceptable:

 

SiteUserWanted
1aabd
1babd
1c 
1dabd
1aabd
2bbd
2dbd
3aab
3bab
4aad
4c 
4dad
4e 
5aa
5c 
5e 

I do not think it is necessary to have the value reflected on every row of each site, however I am open to both types of solutions.

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    Seems like:

     

    Wanted Column =
      CONCATENATEX(
        FILTER('Table',[Site] = EARLIER([Site]) && [User] IN { "a", "b", "d" }),
        [User],,""
      )
    • Anonymous's avatar
      Anonymous
      Not applicable

      You are on the right path.  However, In my example, I should have included a different dimension.  I just updated the tables in the original post to reflect this. 

       

      If the "ID" 1 has multiple "a" values, I only want to have the value "a" once in the "wanted column" and the solution you posted would leave the result "aabd" rather than the desired "abd"

  • v-lili6-msft's avatar
    v-lili6-msft
    Icon for Community Support rankCommunity Support

    hi  Anonymous 

    Just create a calculate column as below:

    Column = 
    IF( [User] IN { "a", "b", "d" }, 
    CONCATENATEX(
        FILTER('Table',[Site] = EARLIER([Site]) && [User] IN { "a", "b", "d" }),
        [User],,"" )
       )

     

    Regards,

    Lin