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: 
bhoomika_10
Contributor
Contributor

Using Set Analysis create bar chart

We need to create a bar chart for years and months . Condition if we select 2012 year data and Aug month then bar chart reflect 2012 year data and previous year 2011 but bar should be from Jan to Aug for both year. Use only set Analysis. 

 

How to do this?

Labels (2)
3 Replies
BrunPierre
Partner - Master II
Partner - Master II

I take it that you want to compare the current and the same period last year's data based on user selection. dimensions.

In  such a case, perhaps these

Current Period

SUM({$<Date = {"$(='>=' & Date(YearStart(Max([Date Field])), 'DD/MM/YYYY') & '<=' & Date(Max([Date Field]), 'DD/MM/YYYY'))"}>}Yourmeasure)

Same period Last Year

SUM({$<Date={">=$(=YearStart(Max([Date Field]), -1))<=$(=AddYears(Max([Date Field]), -1))"}>}Yourmeasure)

bhoomika_10
Contributor
Contributor
Author

Hi Peter, Yes i need to create comparison chart. but how to use both set analysis in one measure.

vinieme12
Champion III
Champion III

There are two ways you can get this done

1)  1 Dimension 2 Measures

Dimension:  YearMonth field (eg values '2022-Jan','2022-Feb')

Measure 1: Current Year

sum({<Datefield={">=$(=Date(Yearstart(Max(Datefield)),'YYYY-MM-DD'))<=$(=Date(Max(Datefield),'YYYY-MM-DD'))"}>}SomeMeasure)

Measure 2: Previous Year

sum({<Datefield={">=$(=Date(Yearstart(Max(Datefield),-1),'YYYY-MM-DD'))<=$(=Date(Addyears(Max(Datefield),-1),'YYYY-MM-DD'))"}>}SomeMeasure)

 

 

2) 2 Dimensions  1 Measure

Create a new field say "MonthNum" that has numeric values for Jan,Feb,Mar  as 1,2,3..12  

Then in chart use below

Dimension1:  Year

Dimension2: Month

 

Measure 1: 

sum({<Year={"$(=Max(Year)),$(=Max(Year)-1)"}

,MonthNum={"<=$(Max(MonthNum))"}

,Month=

>}SomeMeasure)

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.