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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
michelle22
Contributor II
Contributor II

Dynamic set analysis for year and quarter

Hi,

I currently have a table that looks something like this:

Year & QuarterData
2020 Q111
2020 Q25
2020 Q32

 

In my chart, I want that each time I update the table with a new row, the data for the latest Year & Quarter is displayed, as opposed to this, which I'd have to update every time: Sum((<[Year & Quarter]={'2020 Q3'}>) [Data])

I have tried using MaxString without any luck. While this does return the current Year & Quarter, I can't use it within the set analysis to grab the data. Max doesn't work I assume because it's not a number. I've also tried grabbing the last row of data, but can't figure that out either.

Thanks! I would be grateful for any advice. I should also mention that this table is associated with other tables using [Year & Quarter] as the association. 

Labels (1)
1 Solution

Accepted Solutions
Anil_Babu_Samineni

Since some string is involved it always recommend to interpret your values to dual like

I have converted your field to

LOAD Data, Dual([Year & Quarter], QuarterStart(Makedate(Left([Year & Quarter],4)),Right([Year & Quarter],1)-1)) as [Year & Quarter]
INLINE [
Year & Quarter, Data
2020 Q1, 11
2020 Q2, 5
2020 Q3, 2
];

and expression is this

Sum({<[Year & Quarter]={"$(=MaxString([Year & Quarter]))"}>} Data)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

1 Reply
Anil_Babu_Samineni

Since some string is involved it always recommend to interpret your values to dual like

I have converted your field to

LOAD Data, Dual([Year & Quarter], QuarterStart(Makedate(Left([Year & Quarter],4)),Right([Year & Quarter],1)-1)) as [Year & Quarter]
INLINE [
Year & Quarter, Data
2020 Q1, 11
2020 Q2, 5
2020 Q3, 2
];

and expression is this

Sum({<[Year & Quarter]={"$(=MaxString([Year & Quarter]))"}>} Data)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful