Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can I use a calculated dimension in a trellis chart?

I have created a trellis chart where my 1st dimension is Region & 2nd dimension is Year. Everything works great.

My dashboard allows the user to select which periods to compare. For example, if they select 'Year', it will compare this year to last year's sales. If they select 'Quarter', it will compare this quarter to the same quarter of last year, etc.

I would like to enable this functionality on my trellis chart. In other words, I would like to replace the 'Year' dimension with something else. I tried this, but it didn't work:

If(vComparePeriod = 'Year', FiscCalYr,
If(vComparePeriod = 'Quarter', FiscCalQuarter,
If(vComparePeriod = 'Month',FiscCalMonth,
If(vComparePeriod = 'Week', FiscCalWk
)
)
)
)

Has anyone tried using a Trellis Chart with a calculated dimension?

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

To test for which dimension of a cyclic group is selected, use getcurrentfield(YourGroupName). Mind you, I'm not sure if we're on the right track at all, and this seem a bit too "brute force" to me, but continuing on since I'm not sure what else to do:

pick(match(getcurrentfield(YourGroupName),'FiscCalYr','FiscCalQuarter','FiscCalMonth','FiscCalWk')
,sum({<FiscCalYr={"$(CurrentYear)","$(PreviousYear)"}>} POSQty)
,sum({<FiscCalQuarter={"$(CurrentQuarter)","$(PreviousQuarter)"}>} POSQty)
,sum({<FiscCalMonth={"$(CurrentMonth)","$(PreviousMonth)"}>} POSQty)
,sum({<FiscCalWk={"$(CurrentWeek)","$(PreviousWk)"}>} POSQty))

View solution in original post

4 Replies
johnw
Champion III
Champion III

I'm still on version 8.5 and haven't played with Trellis charts, but if you CAN'T do them with a calculated dimension, can you do them with a grouped dimension? Perhaps you could put these four fields in a group, and then use the group as the dimension.

Not applicable
Author

Thanks John. I played around with that, but I'm not sure what to do with the expression. If it's just comparing years, the expression looks like this:

Sum({$<FiscCalYr={"$(CurrentYear)", "$(PreviousYear)"}>} POSQty)

I'm not sure how to test for which dimension in the cyclic group has been selected.

johnw
Champion III
Champion III

To test for which dimension of a cyclic group is selected, use getcurrentfield(YourGroupName). Mind you, I'm not sure if we're on the right track at all, and this seem a bit too "brute force" to me, but continuing on since I'm not sure what else to do:

pick(match(getcurrentfield(YourGroupName),'FiscCalYr','FiscCalQuarter','FiscCalMonth','FiscCalWk')
,sum({<FiscCalYr={"$(CurrentYear)","$(PreviousYear)"}>} POSQty)
,sum({<FiscCalQuarter={"$(CurrentQuarter)","$(PreviousQuarter)"}>} POSQty)
,sum({<FiscCalMonth={"$(CurrentMonth)","$(PreviousMonth)"}>} POSQty)
,sum({<FiscCalWk={"$(CurrentWeek)","$(PreviousWk)"}>} POSQty))

Not applicable
Author

Cool!!!!! This will come in handy! Geeked