Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

A few questions...Load Script, Sum similar transactions.

Hi guys, i am really really new to Qlikview and have encountered some problems which i hope you guys can help me with. Been searching around for answer and trying but doesn't really work.

So an example of my data are as follow:

Transaction NoCustomer IDProduct CodeTransYearTransMonthPrice
000011AA120141100
000022AA220142150
00003

1

AA520142300
000042AA120142600
000052AA220143200
000061AA120143300
000071AA22014388

These are just first few of my data, there are thousands of transactions.

Questions:

1) When i load my script, i tried, date(makedate(TransYear,TransMonth),'MM-YYYY') as TransDate,

   However, the product that appeared as Transdate does not match TransYear and Transmonth of that particular Customer/Transaction.

   For Example, if i open a straight table with all the following data above, the TransDate would be, say for transaction 00001, 05-2015 and

   not 01-2014 as i hoped for. But when i input that formula as expression, it works perfectly fine.

2) I want to get sum purchased by each customer and also by product code. So in expression i would put

sum({<Customer ID,TransMonth>}Price) under the column, SpentMonth, and this would work fine. But after that, i also would like to perform another operation, by summing the SpentMonth for only month 1 and 2, which i cannot do since SpentMonth is not actually a field.

So as i have searched for answers around this forum, a method of solving this would be to perform the SpentMonth in the load script.

But i have absolutely no idea how since set analysis doesnt work in load script part.

It would really be awesome, if someone could kindly shine some light on this.

I sincerely thank you for taking the time to read and reply to this question.

Thank you

15 Replies
t_chetirbok
Creator III
Creator III

Hello!

1) You should change DateFormat: SET DateFormat='MM-YYYY';

and try this date(TransMonth&'-'&TransYear) as Year_Month

2) Can you show some example what do you want to get finally (for your data in question). We'll answer more exactly for you question.

Colin-Albert

Hi Lance,

Dates are the cause of many questions on the forum.

Try using  makedate(TransYear,TransMonth) as TransDate

This will create a datefield of the first of the month, as you have not supplied a day value to makedate.

These blogs should help you with dates.    

     https://community.qlik.com/blogs/qlikviewdesignblog/2012/06/07/get-the-dates-right

     https://community.qlik.com/docs/DOC-3102

Don't try to answer specific queries through the load script. The load script should contain data for every month

For example don't calculate sales for month 1 and month 2 in the load script.

To get the sales for months 1 and 2 use a chart and either let the users select which months they want from a listbox, or use set analysis in the chart expression.

If you can post a few rows of your source data this would help the community point you in the right direction.

Not applicable
Author

Hi Tatsiana and Colin,

Thank you for your replies.

As Colin mentioned, the loadscript should contain data for every month, hence i am trying to

get a field that does sum({<Customer ID,TransMonth>}Price) using the load script.

How do i write that in loadscript?

As mentioned i would like to perform a sum on top of another expression, but i cannot do that since the expression is not a field. Are there any ways around this?

As for an example where i want to get to in the end,

I want to know total spent for every quarter of the year by customer, and product code.

So i would like to know for each customer, how much do they spend each quarter.

Similarly i would like to know for each specific product, how much was sold out.

That is the reason why i am trying to do a sum on top of another sum.

Thank you.

Not applicable
Author

First column is TransYear, 2nd is TransMth, third is the makedate. It screws up if i use it in loadscript.

But if i manually add a calculated dimension using makedate, it works fine.

hihi.PNG

t_chetirbok
Creator III
Creator III

Hi!

I share some example. You can add Quarter field: ceil(TransMonth/3) . And your chart dimensions are Product / Customer and Quarter, expression - sum(Price)

Gysbert_Wassenaar

Can you post a small qlikview document with some sample data to illustrate the problem?


talk is cheap, supply exceeds demand
Not applicable
Author

The sample data is really on top.

What i want to achieve is,

i want 2 tables in the end

Table 1:

Currently we are in year, so i want to display 2014 value as 2015.

TransYearTransMonthTransDatePriceCurrent DateCalculation
2014101-201410001-2015100
2014202-201415002-2015150+300+600
2014202-201430003-2015200+300+88
2014202-2014600
2014303-2014200
2014303-2014300
2014303-201488

*THE CURRENT DATE AND CALCULATION* is what i want to achieve. Do i need to do a separate straight table for that? Maybe that is why it is not working all these while.

Table 2:

Customer IDProduct CodeTransYearTransMonthPriceCustomer IDDateTotal Spent By monthTotal Spent in year
1AA1201411001

01-2015

02-2015

03-2015

100

300

300+88

100+300+300+88
2AA2201421502

01-2015

02-2015

03-2015

0

150+600

200

0+150+160+200

1

AA520142300
2AA120142600
2AA220143200
1AA120143300
1AA22014388

For this table, The Customer ID,Date,Total Spent By Month and Total Spent in Year is what i want to achieve.

Thank you.

Not applicable
Author

So basically i would like to

Date               Sum(price)

2015                sum(price of 2014)

i tried to put into the field, sum({<AddYears(TransYr,-1)>}Price)

But the field doesnt display anything

t_chetirbok
Creator III
Creator III

Hello!

Maybe something like this