Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Experts,
I am trying to use Sum If statement like this
sum(if (Field1 = 'Something' and Field 2 = 'Something'),1,0)as NewField
But its showing error
Kindly help me where i am getting wrong.
Looking forward for response.
Thanks & Regards,
Rajvir
What error are you getting? Make sure that you are using group by clause with other dimensions in the load.
You've got the first ) in the wrong place....
sum(if (Field1 = 'Something' and Field 2 = 'Something',1,0))as NewField
Hi Tresesco, yes i am using group by clause with other dimensions. I am getting invalid expression error when i am using sum if function.
Hi @Or Thankyou, i tried but still getting invalid expression error.
Check that your field names are correct. If they include a space, they should be encased in [ ] or quotes e.g. [Field 2]. You can only use field names that exist in the underlying data source (so if Field1 is something you're calculating in this load script, you can't use it directly).
Maybe try to reverse it:
Instead of:
sum(if (Field1 = 'Something' and Field 2 = 'Something'),1,0) as NewField
Do:
if (Field1 = 'Something' and Field 2 = 'Something',sum(1),sum(0)) as NewField