To include extra columns with formula in CrossTab

Hi,

I have a requirement to design a WebI report where i need to create crosstab as shown below,

------------------Date1----Date2-----Date3
Product1--------100--------200------300 <Diff Btwn Date1 & Date2> <Diff Btwn Date1 & Date3>

Product2--------200--------350------400 <Diff Btwn Date1 & Date2> <Diff Btwn Date1 & Date3>

Product3--------150--------250------350 <Diff Btwn Date1 & Date2> <Diff Btwn Date1 & Date3>

Product4--------250--------300------300 <Diff Btwn Date1 & Date2> <Diff Btwn Date1 & Date3>

for each product i need to display the num_of_product sold on a given date. User can choose 3 dates as shown above. This i am currently able to acheive using crosstab. But the other requirement is i need to come up with 2more columns to the right side of the cross tab and display the different between the product sales on (date1 and date2) and (date1 and date3).

Can anyone tell me how to do this with help of a formula or a variable?
since the user can choose 3 dates randomly from Database, i need to sort the dates in ascending order from left to right. (date1 is minimum, date2 is median and date3 will be maximum). any input is highly appreciated.


maximus82 :india: (BOB member since 2009-08-17)

Could you do the second column with Max([Date]) - Min([Date]? Median might work for the first column, not sure.


Namlemez :djibouti: (BOB member since 2005-03-14)

It depends on how the three dates are being input by the user.

In case you have three different prompts the solution is clear.

But if you have one prompt which receives the list of dates (no idea on how you can be sure that there are exactly three dates in this case) it get a bit more tricky.

Which is the case?


Dmitry Grekov :ru: (BOB member since 2009-09-29)

Try using “previous” function. It will resolve your requirement.


avbaby :india: (BOB member since 2009-05-09)

Hi all,

Thanks for your replies.

Dmitry, the dates are entered in a single prompt and the user can choose 3 dates from the available list of dates.

I have not tried the Previous() solution yet as i just happened to see your replies. Please let me know if you have other suggestions as well.


maximus82 :india: (BOB member since 2009-08-17)

Here’s an easy way

1) Calculate 3 dates (D1, D2, D3):
D1 = min ([Date]) in Report
D3 = max ([Date]) in Report
D2 not in (D1, D3)

(please pay attention to the output context for D1 & D3 )

2) Calculate your cols
C1 = ([Sales] Where ([Date] = D2)) - ([Sales] Where ([Date] = D1))
C2 = ([Sales] Where ([Date] = D3)) - ([Sales] Where ([Date] = D1))


Dmitry Grekov :ru: (BOB member since 2009-09-29)

Hi,

thank you very much for the solution, that helped me to solve 50% of my problem. Now I am stuck in getting the middle date from the user input. The sample logic that I got from you ( ie… D2 not in (D1, D3))
is not working fine as we dont have “not in” option in reports. ( I am not sure if this can be achieved by other means).

So everytime i try to find the middle date, i am getting MULTIVALUE and not as a unique value like what we get in Min() or MAX (). I tried many other options like “previous()” and “Between (;” but they all give me multivalue and i am not able to use that Multivalue middle date for calculations.

It would be great if someone can suggest a way to retrieve the Distinct Middle date value from user input and store it in a 3rd variable.


maximus82 :india: (BOB member since 2009-08-17)

I have a similar issue, when using Month number. I have to calculate the difference in counts between two months. I tried the above using Min and Max but still get both count totals? Any suggestions.


tvanpatten (BOB member since 2008-08-15)

Use different prompt text for the 2 dates, and then store the results of the prompts in 2 different variables. If you get a multi-value error, try using either sum or foreach in your formula. (For the question above, possibly using ForEach([Product]) might have solved the multi-value error problem.)


bkaporch :us: (BOB member since 2008-12-02)