简体   繁体   中英

Tableau - What would the LOD calculation be?

Pretty new to Stack overflow but hoping to get an answer to one of my project work

Region  Sales   Sales (LOD calculation only) 
West    100           0 
East    50           -50 
North   200          100

What would the LOD calculation be to get 0,-50 and 100 in column Sales (LOD calculation only)?

I do understand that row 2 and row 3 are both subtracted from first row. It's easy to do with Table calculation but i am unable to figure the LOD part out

Welcome to Stack Overflow, i am also very new so hope i am helpful.

Looking at your requirement, i believe a LOD expression would not be valid for this. As you have mentioned you are already able to get your results using table calculations, which is the right approach for this type of problem.

LOD expressions are used when you need to do some aggregation in your data which is at a different grain then the selected dimensions.

Hope this helps.

To get sales like the one you displayed, to embed an if statement in an LOD calculation and subtract the initial sales from that number. You could write it as one big calc, but I'll break it down for simplicity.

  1. You'll need a way to assign the amount for the western region to every row. That calculation is

{EXCLUDE[Region]:SUM(IF [Region]='West' THEN [Amount] END)}

  1. Then you subtract the initial sales with a field like this SUM([Sales])-SUM({EXCLUDE[Region]:SUM(IF [Region]='West' THEN [Amount] END)})

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