Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there
If have this calculation
(SUM( AGGR(AVG(EAV), ArticleKey)) / 7.45)
I need to add the following. If [MediaName ]= 'Magazine' AND MediaCountry = 'Denmark' /7 *[ArticleSize] OR [MediaName] = '**bleep**blade & Magasiner' AND [MediaCountry] = Sweden OR Norway /2 *[ArticleSize]
Thanks
I finally managed to figure it out! The problem with the previous one was that instead of having EAV as Else I just needed to replace it with a 1 because it was preceded with / it divides it with the Else statement so replacing it with the 1 means you get the original EAV calculation. Thank you so much for your help Lauri I couldn't have solved it without it. Here is the correct calculation:
(SUM( AGGR(AVG(EAV), ArticleKey))/7.45) /
If([MediaTypeName]= '**bleep**blade og magasiner'AND [MediaCountryName] = 'Danmark' ,7*([Størrelse]),
If([MediaTypeName] = '**bleep**blade og magasiner' AND Match([MediaCountryName], 'Sverige', 'Norge'), 2*([Størrelse]), 1))
Do you mean you need to change the divisor from 7.45 to something else depending on the IF statement? You can put an IF statement in like this:
(SUM( AGGR(AVG(EAV), ArticleKey)) /
If([MediaName]= 'Magazine' AND MediaCountry = 'Denmark', 7*[ArticleSize],
If([MediaName] = '**bleep**blade & Magasiner' AND Match([MediaCountry], 'Sweden', 'Norway'), 2*[ArticleSize])
)
However, if ArticleSize is at the same detail level as ArticleKey, you won't get logical results (or maybe any results) because you are dividing an aggregate SUM by a more detail level number. So you would need to also aggregate your divisor, perhaps with the same SUM(AGGR(AVG())), which would look like:
(SUM( AGGR(AVG(EAV), ArticleKey)) /
SUM( AGGR(AVG(If([MediaName]= 'Magazine' AND MediaCountry = 'Denmark', 7*[ArticleSize],
If([MediaName] = '**bleep**blade & Magasiner' AND Match([MediaCountry], 'Sweden', 'Norway'), 2*[ArticleSize])), ArticleKey))
)
Hi Lauri
Thank you for your suggestion. I still need the 7.45 divisor as this is used to get the price in euros. Using what you suggested the following:
SUM( AGGR(AVG(EAV), ArticleKey))/7.45 /
If([MediaName]= 'Magazine'AND MediaCountry = 'Denmark' ,7*([ArticleSize]),
If([MediaName] = '**bleep**blade og magasiner' AND Match([MediaCountry], 'Sweden', 'Norway'), 2*([ArticleSize])))
works but only for Sweden and Norway. For Denmark it is for reason off by a factor 4. Also when using this I only get results for these categories and none of the other where it should show the 'regular' EAV.
maybe this:
=SUM( AGGR( AVG(
If( [MediaName] = 'Magazine' AND MediaCountry = 'Denmark', EAV * [ArticleSize] / 7,
if( [MediaName] = '**bleep**blade & Magasiner' AND ( [MediaCountry] = 'Sweden' OR [MediaCountry] = 'Norway' ), EAV * [ArticleSize] / 2 ), EAV
) )
, ArticleKey ) )
/
7.45
I hope it can helps.
Unfortunately, that just returns a zero
Let's add parentheses to make sure the calculations are in the correct order, and also the else condition:
( SUM( AGGR(AVG(EAV), ArticleKey))/7.45 ) /
If([MediaName]= 'Magazine' AND MediaCountry = 'Denmark' ,7*([ArticleSize]),
If([MediaName] = '**bleep**blade og magasiner' AND Match([MediaCountry], 'Sweden', 'Norway'), 2*([ArticleSize]), EAV))
I am guessing that EAV is the right thing to put in as the 'regular' EAV.
That just returns 0.1342... for all articles
Is 0.1342 what you get if you calculate ( SUM( AGGR(AVG(EAV), ArticleKey))/7.45 ) / EAV? This would tell us that something is wrong with the entire IF statement, and it's always going to the last Else statement (which contains just EAV).
Just checked and yes that is what is happening
Have you figured out what is wrong with the If statements? They look ok to me, but I don't know your details well enough to be sure. The other possibility is what I initially said: You need to aggregate the result of your If statement.