Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
morganaaron
Specialist
Specialist

Expression for sharing selections between alternate states not working?

Hi all,

I've got a simple dashboard that has an alternate state (called Basket1). I've got two lists of products - the same list, but one in the default state and one in the alternate state.

A user selects a product from both and three tables then tell them who has bought Product A and not B, B and not A and who's bought both.

They all work okay, but in the "both" table I'm trying to show the sales over the selected dates for both products, but only for those who bought both. The table is in the alternate state, and if I *just* show the sales for Product B (the alternate state product) it works fine, as soon as I try and show the sales for A it brings all the customers who have bought A through regardless of if they've purchased B.

The expression that works to show B is:

=Sum({<Year=$::Year, PeriodNumber=$::PeriodNumber, Customer=P({$}Customer)>}Sales)

When I try and show A, this doesn't work:

=Sum({<Year=$::Year, PeriodNumber=$::PeriodNumber, Customer=P({$}Customer), Product=$::Product>}Sales)

Any thoughts as to what I'm doing wrong? I've used $:: as the user makes selections in Year, PeriodNumber and Product and P as they don't select any Customers, but want any possible ones with the selections that have been made, however I've tried using $:: for customer and it gives the same result.

Thanks!

4 Replies
tresesco
MVP
MVP

Try like:

=Sum({<Year=$::Year, PeriodNumber=$::PeriodNumber, Customer=P({$}Customer), Product=Basket1::Product>}Sales)

If this doesn't work, try to share your sample qvw.

morganaaron
Specialist
Specialist
Author

Oops - sorry hadn't checked my results properly. This is the wrong Product that it then pulls through, I need the product from the default state, not the one in Basket1.

I think it's to do with the dates, as if I add the same date calendar to the alternate state and make the same year/period selections it works - but not sure why it would ignore the date selections?

morganaaron
Specialist
Specialist
Author

Here's a crude example of what it's doing - in this example, both Customer A and B have bought Prod1 and Prod2, but only A has bought both on both dates - however in the "both" table, when I try to add the sales for Prod1, it brings Customer B into the table even though they haven't bought any of Prod2 on this date.

morganaaron
Specialist
Specialist
Author

I've managed to solve it in the mean time by putting document triggers to share the default date values with the alternate state date fields, and then have used:

=Sum({<Customer=P({Basket1}Customer)>}Sales)

=Sum({Basket1<Customer=P({$}Customer)>}Sales)

With the object in the default state.

Any better solutions would be welcome however!