10 Replies Latest reply on Jun 22, 2018 1:54 PM by Jim Dehner

# Calculating the differnce of a measure across a dimension

Hi, I'm trying to understand how to either structure a table calculation, or use some kind of LOD calculation to look at the difference between two sample sets

The goal is to understand the variation between a proposed change in sampling method, in excel, I'd simply pivot the data and calculate the difference, but I'm really challenging myself to work more in tableau, but I just can't figure this one out.

I've uploaded  a very simple dummy data set that has the number of people who've seen the movie in 1 or 2 weeks, in either sample set A or Sample set B (which actually has people from A & B).  I want to see how many more people (in flat number, but also percent difference) saw the movies between the two sample sets.

I've managed to do it when I've uploaded the data with the values across several columns ( which is fine for 2 sample and 2 week, but begins to get cumbersome when you have to re-make the calculations for each possible variable combo)

I'll take any ideas you've got!

Thanks

• ###### 1. Re: Calculating the differnce of a measure across a dimension

Hi Laura,

Thanks

Deepak

• ###### 2. Re: Calculating the differnce of a measure across a dimension

Hi

see the attached

its easier to expain when you send us your twbx workbook -

but the superstore example will have to do

your instinct is correct you want to pivot the data - tableau and all other database oriented systems (like access) like data that is tall and narrow

the "columns" are measures and dimensions - dimensions categorize data Measures contain the actual values

so you want to end up with columns like movie titles, sample, and dates (for dimensions) and then you values as a single column form measures

then the table calculations are based on the table you create when you bring values to the viz

this is the diff WOW

computed across the table

this is the percent diff

you dont need to remember them just right click the measure and add a table calc

and select from the drop down

there are some formating things that could be applied to the table but this is the basic

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

1 of 1 people found this helpful

• ###### 4. Re: Calculating the differnce of a measure across a dimension

Jim,

Thanks so much, this was very helpful.  I was able to re-cerate your calculations into my dummy data set, but the percent change calculation still seems a bit off.

I attached my updated workbook (to the original message, I think).  Did I implement this correctly?

-Laura

• ###### 5. Re: Calculating the differnce of a measure across a dimension

see the attached

this is what it returns

the formulae are

and

each is calculated like this

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

1 of 1 people found this helpful
• ###### 6. Re: Calculating the differnce of a measure across a dimension

thanks!  I guess I was missing a parenthesis in mine!

Cheers!  Bonus points if you can get it into a bar chart that shows the sample group A stacked with the difference between the two, that will be my next exploration into visualizing my data sets

-L

• ###### 7. Re: Calculating the differnce of a measure across a dimension

like this?

• ###### 9. Re: Calculating the differnce of a measure across a dimension

for clarity I suppose that should read: "increase in sample (B-A)"

• ###### 10. Re: Calculating the differnce of a measure across a dimension

I see you went to Pencil perfect for that on visual

see the attached - it the best I can do on Friday afternoon

it returns this

calculate the difference as

Jim

Have a good weekend