简体   繁体   中英

Distinct sum of values in Tableau

I have a data with columns called Brand, Market and Target. The Brand having members like A, B, C & D repeats across 2 kinds of Market - OPL and CPL. So the Target for each of Brand and Market also repeats in column Target, as in below image:

在此处输入图片说明

All I would want is to get sum of Target for each of Brand at OPL (highlighted in orange) and sum of Target for each of Brand at CPL (highlighted in yellow)

So sum for OPL should be 10000 + 7000 + 4000 + 9000 = 30000 and sum for CPL should be 5000 + 2000 + 8000 + 3000 = 18000

I used a logic like

IF [Market] = 'OPL' THEN {FIXED [Brand]+[Market] : MIN([Target])} END

Image as below:

在此处输入图片说明

which gave me total of target at OPL which is 58000, which is not the one I wanted. Please help me with correct calculation, do let me know for any further details.

Try this:

SUM( { FIXED [Brand], [Market]: AVG(Target) } )

Averaging within each Market and Brand will eliminate the duplicates in your sum.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM