Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Srinivas
Creator
Creator

How to get only few month data based on monthnumbers.

Dear all,

Please see below My data,

Here i need for 2013 year hole sales and for 2014 year Jan to May data i need in my chart.

i wrote expression like this way but it's not working properly. =sum({$<Year = {$(=max(Year))}, Month =>} AOP_Cts/1000)

2013= here need Jan to Dec ...hole data

2014 = here i need Only Jan to May only

how we can write expression....

              Year             Month            Sales
2013120.946
2013221.061
2013321.92
2013421.848
2013516.645
2013623.912
2013725.137
2013824.963
2013925.113
20131023.429
2013115.267
20131221.411
2014116.141
2014215.855
2014319.934
2014421.189
2014513.436
2014620.667
2014724.445
2014824.596
2014925.537
20141022.119
2014111.271
20141215.13

Advance Thanks

Munna

7 Replies
alexandros17
Partner - Champion III
Partner - Champion III

The best thing is to create a new field in your script that concatenate year and month:

Load

...

year * 100 + month as yearmonth

...

resident

...

In this way you will have a field like 201307 ... 201401, 201402 ...

the expression become:

sum({$<yearmonth = {'<=201405'}>} AOP_Cts/1000)

obviously you can use a variable for the current month ...

Let me know

sundarakumar
Specialist II
Specialist II

i would suggest to create yeamonth field in the back end and use it in set analysis.

Here u have condition like u should show all data before 2014 may,

can be done like

sum({<Yearmonth={'<201405'}>}sales)

u wil need to do some changes in back end like

num(Year&if(len(Month)=1,'0'&Month,Month)) as Yearmonth

U can even move 201405 to a vaiable for further modifications ion it.

-Sundar

Srinivas
Creator
Creator
Author

Hi Sundarakumar,

As per ur expression we are getting only one (May)month data but i want in year 2014 jan+feb+mar+Apr+May... this five month data in this year, And Previous year 2013 i want hole data like Jan+feb+Mar....upto Dec..

Advance Thanks

Munna

jagan
Luminary Alumni
Luminary Alumni

Hi Munna,

Try like this

Script:

TableName:

LOAD

*,

Num(Year & Num(Month, '00')) AS YearMonth

FROM DataSource;

Now use this expression

sum({<Year=, Month=, Yearmonth={'<201405'}>} Sales)


Hope this helps you.


Regards,

Jagan.

sundarakumar
Specialist II
Specialist II

sum({<Yearmonth={     <   201405}>}sales)

please note the less than symbol in set analysis it will look for yearmonths which is less than 201405 which means all the years and month before it. if u want a from date also u can very well add it as

sum({<Yearmonth={ < 201405>201301}>}sales)

we would suggest to move these numbers to  variables to make it dynamic.

-Sundar

Anonymous
Not applicable

Hi Munna,

After creating Yearmonth column, you may try this :

sum({<Yearmonth={<=201405}>}sales)



Regards,

Chinna

Srinivas
Creator
Creator
Author

Hi Jagan,

It's working fine but statically it shows correct when i select any one there's no any changes ..it is not a Dynamically .

Could you please check once more.

Regards

Munna