Hi,
I am wanting to calculate what our national advertising is based on the sourcecode. The following code I have is
National = CALCULATE(sum(insertBK[InsertNetCost]),adtrans[SourceCode] = "BA430", adtrans[SourceCode] = "CA148",adtrans[SourceCode] = "HX355",adtrans[SourceCode] = "MD301")
However it is returning blank in the table, Any help appreciated.
Thanks
Chris
Solved! Go to Solution.
Hi Chris,
Filter Arguments in CALCULATE are evaluated with AND operator. If you would like to evaluate the conditons in OR operator, You can either use || operator or OR.
You provide several filter conditions based on the same column. Those are contradictory.
Basically, your expression reads as :
Calculate SUM(insertBK[InsertNetCost]) WHERE adtrans[SourceCode] = "BA430" AND adtrans[SourceCode] = "CA148" AND adtrans[SourceCode] = ...
Obviously, this will not work.
You probably intended to write something like:
Calculate SUM(insertBK[InsertNetCost]) WHERE adtrans[SourceCode] = "BA430" OR adtrans[SourceCode] = "CA148" OR adtrans[SourceCode] = ...
You could write this, this way :
CALCULATE( SUM(insertBK[InsertNetCost] , adtrans[SourceCode] = "BA430" || adtrans[SourceCode] = "CA148" || adtrans[SourceCode] = ... )
Alternatively, you may want to look at the IN operator:
In that case, you want to see items where [SourceCode] <> "BA430" AND adtrans[SourceCode] <> "CA148" , AND ...
The && operator is what you need.
adtrans[SourceCode] <> "BA430" && adtrans[SourceCode] <> "CA148" && adtrans[SourceCode] <> "HX355" && adtrans[SourceCode] <> "MD301"
You provide several filter conditions based on the same column. Those are contradictory.
Basically, your expression reads as :
Calculate SUM(insertBK[InsertNetCost]) WHERE adtrans[SourceCode] = "BA430" AND adtrans[SourceCode] = "CA148" AND adtrans[SourceCode] = ...
Obviously, this will not work.
You probably intended to write something like:
Calculate SUM(insertBK[InsertNetCost]) WHERE adtrans[SourceCode] = "BA430" OR adtrans[SourceCode] = "CA148" OR adtrans[SourceCode] = ...
You could write this, this way :
CALCULATE( SUM(insertBK[InsertNetCost] , adtrans[SourceCode] = "BA430" || adtrans[SourceCode] = "CA148" || adtrans[SourceCode] = ... )
Alternatively, you may want to look at the IN operator:
Ah think I get what you mean, wil try it out.
It works! Thanks Guys!
Thanks Laurent,
I wanting it to accumativley add them as they are all the national sourcecodes, so eventually I am wanting to put a measure in my table which gives me the national split.
Thanks
Chris
Hi Chris,
Filter Arguments in CALCULATE are evaluated with AND operator. If you would like to evaluate the conditons in OR operator, You can either use || operator or OR.
Hi Bhavesh
Thanks for replying I am wanting to accumativley add them so looking for an AND.
It just seems to be returning 0.
Thanks
Chris
If you want to see items with a sourcecode BA430 and items with a sourcecode CA148, you actually want to use OR.
You want to see all items with either a sourcecode BA430 or a sourcecode CA148 or ...
If I am wanting the opposite I have put
Local Split = CALCULATE( SUM(insertBK[InsertNetCost]), adtrans[SourceCode] <> "BA430" || adtrans[SourceCode] <> "CA148" || adtrans[SourceCode] <> "HX355" || adtrans[SourceCode] <> "MD301" )
but that is giving the same value as SUM(insertBK[InsertNetCost]) with them in.. any idea?
In that case, you want to see items where [SourceCode] <> "BA430" AND adtrans[SourceCode] <> "CA148" , AND ...
The && operator is what you need.
adtrans[SourceCode] <> "BA430" && adtrans[SourceCode] <> "CA148" && adtrans[SourceCode] <> "HX355" && adtrans[SourceCode] <> "MD301"
Thank you very much for the help laurent
The join colums is [adnumbr].
Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!
User | Count |
---|---|
104 | |
73 | |
70 | |
47 | |
46 |
User | Count |
---|---|
161 | |
85 | |
76 | |
68 | |
67 |