Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Day Month Dimension

I would like to have both years show up on the same line/bar graph.

Date(Date,'MM/DD') - Right now I get two entries for 01/01, with 2 years of data. That makes sense, but I want to compare the two years, and I would like them be combined.

Any ideas?

Thanks,

Alex

8 Replies
clisboa_noesis
Partner - Creator
Partner - Creator

Hi Alex,

You could do it in multiple ways, i'll give you one which i believe is best.

create two variables:

vYearCurrent

=max(Year)

vYearPrevious

=(

          if(

                    GetPossibleCount(Year)=2,

                    min(Year),

                    max(Year-1)

          )

)

and now you can use these variables in the set analysis with two expressions, one for each year. Something like:

Current Year

sum({< Year= {"$(=vYearCurrent)"}>} Value)

Previous Year

Current Year

sum({< Year= {"$(=vYearPrevious)"}>} Value)

The vYearPrevious is done that way so that when the user want to analyse non-contigous years the graph will remain usefull. If you want it simpler, this variable can be just =max(Year-1).

Hope it helps

Regards,

Carlos

Not applicable
Author

The vYearPrevious variable did not work for me when I used LET. When I used SET, it didn't error but it does not work in my calculation.

jagan
Luminary Alumni
Luminary Alumni

Hi,

I think this variables should be created in

Settings Menu -> Variable Overview -> Add

This should not be created in script.

You can also do this without using variables

Current Year

sum({< Year= {'$(=Max(Year))'}>} Value)

Previous Year

sum({< Year= {'$(=Max(Year) - 1)'}>} Value)

Regards,

Jagan.

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

I think the solution is very simple:

Line chart with 2 dimensions: Year and Month.

Months will supply the 12 values for the X-axes, and Year will cause multiple line series toe be created.

If you have more than 2 Years of data, and you need to limit the scope for the chart, you can also add a Set Analysis condition in your expression to only count last 2 years.

cheers,

Oleg

Not applicable
Author

Hi Oleg,

The issue is that they want to see the data down to the date. Like my example.

Not applicable
Author

And Jagan. I can't exactly do it like that because my client wants to see rolling 12 months in the graph.

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

Create a new field

MonthName(Date) as MonthYear

Then use this set expression.

Sum({<MonthYear = {">=$(=MonthName(addmonths(max(Date),-12)))"}>}FieldName)

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
ziabobaz
Creator III
Creator III

OMG
I have spent the whole day playing with set analysis to display various periods on the same X chart, until i saw you very simple solution. Thank you!