3 Replies Latest reply on Sep 19, 2018 5:35 AM by Mahfooj Khan

# Fixed Computations across different Rows (Row order not guaranteed) -- Possible?

I want to calculate the change in market share for products.

My idea was:

-Get the row where the offset date = the date in the other row
-Now subtract the market share value in offset date row from the market share value in our date row,

but this didnt work.

Note: There will normally be more than two months, this is a mockup.

I know I can do this in the datasource, but having this capability in Tableau would make life so much easier.

The problem is that i don't really understand how calculations are evaluated. I understand the query pipeline, and how the calculations work, but I am unable to understand why this doesn't work. It would be great to be able to do non-view dependent (materialized) calculations where we can decide which rows to use.

• ###### 1. Re: Fixed Computations across different Rows (Row order not guaranteed) -- Possible?

Hi,

Try this,

{FIXED [Country],[Product]: SUM(IF [Date]={FIXED :MAX([Date])} THEN [Market Share] END)}

-

{FIXED [Country],[Product]: SUM(IF DATETRUNC('month',[Date])=DATEADD('month',-1,{FIXED :MAX([Date])}) THEN [Market Share] END)}

Let us know if this help.

Mahfooj

1 of 1 people found this helpful
• ###### 2. Re: Fixed Computations across different Rows (Row order not guaranteed) -- Possible?

This doesn't get a value for prior months (when I add months), but for my use case that's ok.

• ###### 3. Re: Fixed Computations across different Rows (Row order not guaranteed) -- Possible?

In that case you have to use table calculation which will server your purpose easily.