How to merge two rows in one?



Let me show you what my table looks like and what I want to achieve this should be the easiest way to explain:


Account  SubAccount Integration

AccountA Subaccount1 IntegrationA

AccountA Subaccount2 IntegrationB

AccountB Subaccount1 IntegrationA


I then want to create an additional column in beast mode that checks if Account A contains IntegrationA and Integration B, if Yes then return TRUE otherwise return FALSE. Something like this: 


CASE WHEN AccountA.Integration = (IntegrationA AND Integration B) THEN 'TRUE' ELSE 'FALSE' END


The result should look like this:


Account  IntegrationBeastMode

AccountA TRUE

AccountB FALSE


Hope this makes sense. 

Best Answer

  • Godiepi
    Godiepi 🟣
    Accepted Answer

    Hi @user16640 


    If only you want to check for that in AccountA then the 1st  beastmode would work,

    if you want to check for those conditions in all accounts you'll need to remove the condition for accountA using the beastmode number 2 below


    BeastMode to check only on AccountA

    case when `Account` = 'AccountA'
    then case when sum(case when `Integration` in ('IntegrationA', 'IntegrationB')
    then 1 else 0 end) = 2
    then 'TRUE' else 'FALSE'
    else 'FALSE' end

    BeastMode to check on all accounts where Integration is A and B

    case when sum(case when `Integration` in ('IntegrationA', 'IntegrationB')
    then 1 else 0 end) = 2
    then 'TRUE' else 'FALSE'


    Screen Shot 06-27-19 at 12.05 PM.PNG