I've an excel file with 4 fields :a,b,c,key.
I need to check in QV script that for each row a,b,c there is only on key.
The rows that have diffrent keys should be the result.
for example this is an uncorrect situation that I need to catch :
key | c | b | a
111 | test3 | test2 | test1
222 | test3 | test2 | test1
anyone has an idea how can it be done in qlikview?
thanks,
Lena.
Interesting problem. I suggest treating columns c + b + a as a composite key and counting the number of unique values in the field key for each composite key. Here is one way to do that (QlikView script):
DATA:
LOAD key, c, b, a
FROM some_file.xls;
LEFT JOIN(DATA)
LOAD c, b, a, COUNT(DISTINCT key) AS key_count
RESIDENT DATA
GROUP BY c, b, a;
Your data model now has a 5th column named key_count. You can now use key_count in a chart or list box, or another LOAD statement with a WHERE clause, to filter the rows that have 2 or more values in the field key. To expand on your sample data:
key | c | b | a | key_count
111 | 3 | 2 | 1 | 2
222 | 3 | 2 | 1 | 2
333 | 4 | 3 | 2 | 1
444 | 5 | 4 | 3 | 1
In a list box or LOAD statement, you can now easily find the rows where key_count > 1. I hope this helps!
Related
I have a table (1) in Excel, with two columns, in which at the first column (A) there are some numbers and at the second column (B) there are some letters. I want to have a method to make another table (2) from (1) to put different letters at the first column then to put in each row the numbers that were corresponded to letters in table (1).
For example, let the table (1) is:
| A | B |
|---|---|
| 1 | a |
| 1 | b |
| 2 | a |
| 2 | c |
| 3 | b |
| 4 | b |
What is a method in Excel which make the following combination table:
| a | 1 | 2 | |
| b | 1 | 3 | 4 |
| c | 2 | | |
in which letters are in first column and in each row there are the numbers that were in relationship with the row's letter in table (1)?
As per below screenshot use below formula to C1 cell.
=UNIQUE(B1:B6)
And following formula to D2 cell then drag down
=TRANSPOSE(UNIQUE(FILTER($A$1:$A$6,$B$1:$B$6=C1)))
I have a table that looks the following:
| A | B | C |
| 40 | 1 | 1 |
| 180 | 2 | 2 |
| 34 | 1 |
| 2345 | 3 |
| 23 | 1 |
| 1 | 2 |
| 4354 | 3 |
| 2 | 2 |
| 343 | 4 |
| 2 | 2 |
| 45 | 1 |
| 23 | 1 |
| 4556 | 3 |
I want to get the sum of all fields in A where B is neither 1 nor 2 or any other value from colum C. This column contains the values of B where values from A should not be considered for the sum.
I do not know which values B might contain, those values are random and could grow larger, I just wanted to make the example small. My current solution is
{=SUMIF(B1:B13,C1:C2,A1:A13)}
so i can set the lines that should be excluded from the sum in column C. Unfortunately, the current solution does not solve my problem but something different -- it sums up the corresponding entries by value in C. My preferred solution would look something like
=SUMIF(B1:B13,"<>{1, 2}",A1:A13)
=SUMIF(B1:B13,"<>"&C1:C2,A1:A13)
if that were possible (it isn't). I would like to have:
a field (with a list, for example) or column where i can put in the values of B that I do not want to be part of the sum over A.
a method that works with Open Office as well as Excel. I prefer an OO solution.
You could use an array formula so that you can multiply each value in A with a condition. That condition can be any valid Excel formula, so, for instance, you could use MATCH to test if the B value occurs in C:
=SUM((A1:A13)*ISNA(MATCH(B1:B13,$C:$C,0)))
The ISNA function returns TRUE when the match fails, which in a multiplication is used as a numerical value 1. FALSE will make the product 0.
Make sure to enter this as an array formula with Ctrl+Shift+Enter
I have a sheet containing four columns in total A, B, C, and D. Column A has the corresponding value in B and Column C has the corresponding value in D. I want to use a formula that basically compares each corresponding value of Col A with the corresponding value of Col C.
| A | B | C | D |
| 1 | 100 | 2 | 2000 |
| 2 | 200 | 3 | 3000 |
| 3 | 300 | 1 | 1000 |
The above shows that 100 is the corresponding value of index 1 and 1000 is the corresponding value of the same index but in another column. How can i list them next to each other depending on index like below please.
| 1 | 100 | 1 | 1000 |
| 2 | 200 | 2 | 2000 |
This whole concept is then to match both corresponding values and see if they match or not. Thanks a lot.
if you are working on a very long list with the index in column A & C are not completely identical, then you can use vlookup() or index()+match() to create your table. Otherwise, just sort column C & D as Trauger suggested.
Suppose I have the following pivot:
Dim 1 | Dim 2 | Count
A | B | 1
A | C | 3
B | A | 2
B | D | 4
when right-clicking on any number in Count column, I've selected Sort from largest to smallest and god the following sorting:
Dim 1 | Dim 2 | Count
A | C | 3
A | B | 1
B | D | 4
B | A | 2
What is really required is to sort the pivot table across the dimensions to get the following result:
Dim 1 | Dim 2 | Count
B | D | 4
A | C | 3
B | A | 2
A | B | 1
How can I do that please? Complementary requirements: copying the values is less acceptable as the source data and filters might be updated, so I'd like to keep the sorted pivot in automatic sync, VBA coding is another less feasible option.
You should be able to right click on the column you want to sort by and click Sort.
It seems like a simple problem, but I do not manage to solve it. I have the following tables:
Values
| Key | Value |
|-----|-------|
| A | 1 |
| B | 2 |
| C | 3 |
Results
| Foo | Bar |
|-----|-----|
| A | B |
| C | B |
| A | A |
| B | C |
| ... | ... |
What I am looking for is a final row in the Results table that looks for the key in the Values table, takes its value and sums all the keys in a column (i.e. FOO and BAR). The final result would be:
| Foo | Bar |
|-----|-----|
| A | B |
| C | B |
| A | A |
| B | C |
|-----|-----|
| 7 | 8 |
I have been trying with different VLOOKUP, INDEX and MATCH functions, but still I am not able. Any ideas?
I asume you want a solution without extra columns. Then you are into Array formulas (a.k.a CSE or ControlShiftEnter functions).
Combination of {=SUM(VLOOKUP(...))} doesn't work, but combination of {=SUM(SUMIF(...))} does:
in A12 enter =SUM(SUMIF($A$1:$A$3;A7:A10;$B$1:$B$3)) and save with Ctrl+Shift+Enter. You then can copy this to B12.
Problem is you will need to change the Array function every time you add values to the list A7:B10 (or you initially make the range sufficiently large) ... this would speak more for extra =VLOOKUP() columns as suggested by CustomX.
I'm not sure of other solutions, but you could solve this by using an extra 2 columns, E and F for example.
Enter this in column E: =VLOOKUP(C2;$A$1:$B$3;2;0)
Enter this in column F: =VLOOKUP(D2;$A$1:$B$3;2;0)
Pull the formulas down and add a SUM at the bottom of column C and D to calculate columns E and F.
Extra: These are the columns I used for your examples.
Key = column A
Value = column B
Foo = column C
Bar = column D