Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
yann_courtet
Partner - Contributor II
Partner - Contributor II

Set analysis and Value List

Hi,

Here are my data :

ProductYearMonthQuantity
Potatoes201718
Potatoes2017313
Apples201714
Apples201724
Potatoes201819
Potatoes201836
Apples201811
Apples201823
Potatoes2019110
Potatoes2019315
Apples201912
Apples201925

 

I want to create a table that looks like this (based on the selection of a month / year)

 2019 2018 
 2YTM2YTM
Potatoes0909
Apples5734


If I create a table with 4 columns (and without ValueList), it's working, except that the formating sucks

If I try to use the ValueList, one of the value is wrong when there is no data for the current selection :
YTM / Potatoes 2019 displays 9 instead of 10.

See qvw attached.  ValueList.qvw 

Does someone has any idea about how to solve that ?

Thanks

Yann

1 Solution

Accepted Solutions
yann_courtet
Partner - Contributor II
Partner - Contributor II
Author

So, I found the following Workaround :


Do not use ValueList, but create an Island instead
In this case :

Island:
LOAD * inline [
Selection
Year N,
Year N-1];

And replace the formula :
=If(ValueList('Year N', 'Year N-1') = 'Year N',
Sum({$<Month = {"<= $(=Only(Month)) "}>}Quantity),
Sum({$<Month = {"<= $(=Only(Month)) "}, Year = {"$(=Only(Year)-1)"}>}Quantity)
)

by :

If(maxstring(TOTAL <Selection>{1} Selection) = 'Year N',
Sum({$<Month = {"<= $(=Only(Month)) "}>}Quantity),
Sum({$<Month = {"<= $(=Only(Month)) "}, Year = {"$(=Only(Year)-1)"}>}Quantity)
)

View solution in original post

1 Reply
yann_courtet
Partner - Contributor II
Partner - Contributor II
Author

So, I found the following Workaround :


Do not use ValueList, but create an Island instead
In this case :

Island:
LOAD * inline [
Selection
Year N,
Year N-1];

And replace the formula :
=If(ValueList('Year N', 'Year N-1') = 'Year N',
Sum({$<Month = {"<= $(=Only(Month)) "}>}Quantity),
Sum({$<Month = {"<= $(=Only(Month)) "}, Year = {"$(=Only(Year)-1)"}>}Quantity)
)

by :

If(maxstring(TOTAL <Selection>{1} Selection) = 'Year N',
Sum({$<Month = {"<= $(=Only(Month)) "}>}Quantity),
Sum({$<Month = {"<= $(=Only(Month)) "}, Year = {"$(=Only(Year)-1)"}>}Quantity)
)