Qlikview aggration with conditions - expression

I have some data like below -
id, fn, ln, logdate
1, Rob, Hep, 01-04-2010
2, Rob, Hep, 09-04-2010
3, Rob, Hep, 10-10-2012
4, Rob, Hep, 01-12-2009
5, Peter, Cheng, 02-10-2010
6, bob, Pen, 05-10-2009
7, Peter, Cheng, 01-10-2009
8, Kim, Rany, 08-01-2010
I will have to write an expression
Group the above data by fn+ln.
From the Group get the record of min(logdate)
For each min logdate from above, find count if the date is above '01-01-2010'
So in this example -
I should get count as one. (Rob Hep's min log date is 01-12-2009 and Peter Cheng's 01-10-2009 and bob Pen's is alos 05-10-2009 all of them are before 01-01-2009)
Can some one help me in writing the expression for it please?

First the load script:
Table:
Load id,
fn,
ln,
logdate,
fn & ' ' & ln as name,
num(Date#(logdate, 'DD-MM-YYYY')) as numdate inline [
id, fn, ln, logdate
1, Rob, Hep, 01-04-2010
2, Rob, Hep, 09-04-2010
3, Rob, Hep, 10-10-2012
4, Rob, Hep, 01-12-2009
5, Peter, Cheng, 02-10-2010
6, bob, Pen, 05-10-2009
7, Peter, Cheng, 01-10-2009
8, Kim, Rany, 08-01-2010
];
I added one field for the name and an other one for the numeric value of the date. That makes it easier (even possible?) in the set expression.
Then I added a variable
vNumdate =num(date#('01-01-2010','DD-MM-YYYY'))
so you can edit it in the dashboard.
In the dashboard I have all the fields, a textfield containig the vNumdate and a
diagram (type table).
The dimension of the diagram is the field name
And the formulas are:
Min date
=min(numdate)
Count since 1.1.10
=Count({$<numdate = {">=$(vNumdate)"}>} numdate)
And thats the simple dashboard in qlikview:
(Hope I got it right.)

Related

There is error while uploading csv file in play console. How to avoid it?

invalid row(s) in the CSV file: 1, 2, 3, 4, 5, 6, 7, 8, 9 ..etc
Your format is incorrect should make like this:
As in picture you only can add email address in one column with multiple rows

SSRS date expression tweak

In SSRS I am currently using this expression:
=IIF(Today() >= DateSerial(Year(Today()), 4, 1),DateSerial(Year(Today()), 4, 1), DateSerial(Year(Today()) - 1, 4, 1))
In a date parameter (default values, specify values). This gives me 01/04/2018.
However for one particular report it would be helpful for the date to default to the previous year - e.g. 01/04/2017.
I've tried to tweak the above expression to make this work, but haven't succeeded. Can this expression be changed to go back one year?
Thanks.
=IIF(Today() >= DateSerial(Year(Today()), 4, 1),DateSerial(Year(Today())-1, 4, 1), DateSerial(Year(Today())- 2, 4, 1))

Getting error while importing customers in Magento community

I am getting this error while importing customers in the community version of Magento. There is no such column like 'reward_update_notification' and 'reward_warning_notification'.
Required attribute 'reward_update_notification' has an empty value in rows: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Required attribute 'reward_warning_notification' has an empty value in rows: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Magento version is 1.9.0.1
Thanks
I do not know what is causing the problem. When you export new customers the column is there but the fields are empty.
Add the columns (with field names on line 1) and fill them with "1"
it works.
Erik

Oracle query to compare result row with another and output if match found

I have a dataset and I am trying to find results that reference each other. I have a table that has "Applications" in it. There are 2 parties (people) involved with an Application. These are the "Applicant" and the "Receiver".
I need to find out how to obtain data where person "A" has been an Applicant and person "B" has been a Receiver and then where they have forwarded another Application in reverse. So where Person "B" is the Applicant and person "A" is the Receiver. I need to return both of those lines as 1 row in my result set.
My Data Structure looks like this:
Application ID, Applicant Name, Applicant DOB, Receiver Name, Receiver DOB
1, Bob SMITH, 12/06/1980, Joe SMITH, 10/10/1979
2, Joe SMITH, 10/10/1979, Bob SMITH, 12/06/1980
3, Betty DAVIS, 15/05/1986, Barry DAVIS, 29/07/1981
4, Barry DAVIS, 29/07/1981, Betty DAVIS, 15/05/1986
As you can see there are 4 applications but in reality only 2 "Cross Applications". I am trying to get an end result to look like this showing the unique Cross Applications:
Application ID 1, Applicant Name 1, Applicant DOB 1, Receiver Name 1, Receiver DOB 1, Application ID 2, Applicant Name 2, Applicant DOB 2, Receiver Name 2, Receiver DOB 2
1, Bob SMITH, 12/06/1980, Joe SMITH, 10/10/1979, 2, Joe SMITH, 10/10/1979, Bob SMITH, 12/06/1980
3, Betty DAVIS, 15/05/1986, Barry DAVIS, 29/07/1981, 4, Barry DAVIS, 29/07/1981, Betty DAVIS, 15/05/1986
The only thing I can compare between the two Applications is the Name and DOB (This is a constraint placed on me. It's annoying as sometimes people spell names differently or put in wrong DOB). I only want to return the cross applications, where both people are matched.
I think I'd need to load Row "N" into a cursor and compare the Name and DOB with every other row in the dataset (N+1 to N+n) and if any matches are found then to put them into the output and move on to the next row. I'm not sure how to do this and would like some help if anyone can give any advice. Thanks!
Kindly try the below
SELECT A.Application_ID "Application ID1",
A.Applicant_Name "Applicant_Name1",
A.Applicant_DOB "Applicant_DOB1",
A.Receiver_Name "Receiver_Name1",
A.Receiver_DOB "Receiver_DOB1",
B.Application_ID "Application ID2",
B.Applicant_Name "Applicant_Name2",
B.Applicant_DOB "Applicant_DOB12",
B.Receiver_Name "Receiver_Name2",
B.Receiver_DOB "Receiver_DOB2"
FROM Applications A, Applications B
WHERE A.Applicant_Name=B.Receiver_Name
AND B.Applicant_Name=A.Receiver_Name
AND B.Receiver_DOB =A.Applicant_DOB
AND A.Receiver_DOB =B.Applicant_DOB;

Two (seemingly) identical queries, one is faster, why?

Two seemingly identical queries (as far as a newbie like me can tell, but the first is faster overall in the partial template rendering time (nothing else changed but the ids statement). Also, when testing through rails console, the latter will visibly run a query, the former will not. I do not understand why - and why the first statement is a few ms faster than the second - though I can guess it is due to the shorter method chaining to get the same result.
UPDATE: My bad. They are not running the same query, but it still is interesting how a select on all columns is faster than a select on one column. Maybe it is a negligible difference compared to the method chaining though.
ids = current_user.activities.map(&:person_id).reverse
SELECT "activities".* FROM "activities" WHERE "activities"."user_id" = 1
SELECT "people".* FROM "people" WHERE "people"."id" IN (1, 4, 12, 15, 3, 14, 17, 10, 5, 6) Rendered activities/_activities.html.haml (7.4ms)
ids = current_user.activities.order('id DESC').select{person_id}.map(&:person_id)
SELECT "activities"."person_id" FROM "activities" WHERE "activities"."user_id" = 1 ORDER BY id DESC
SELECT "people".* FROM "people" WHERE "people"."id" IN (1, 4, 12, 15, 3, 14, 17, 10, 5, 6) Rendered activities/_activities.html.haml (10.3ms)
The purpose of the statement is to retrieve the foreign key reference to people in the order in which they appeared in the activities table, (on its PK).
Note: I use Squeel for SQL.
In the first query, you've chained .map and .reverse, while in the second query, you've used .order('id DESC') .select(person_id) which were unnecessary, if you added .reverse

Resources