Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Showing unique values only

Hello,

I am stuck here and I tried with DISTINCT, but I cannot get it done.

This is the script:

Article:

LOAD *,

RowNo() as "ROW_Article",

DAY(LASTORDER)      AS "DAY",

MONTH(LASTORDER)    AS "MONTH",

YEAR(LASTORDER)      AS "YEAR"

;

SQL

SELECT Distinct

ID AS ARTICLEID,

DESCRIPTION,

EXTERNALIDENTIFIER AS ARTICLENO,

LASTORDER

FROM MATERIAL

;

This is the table:   

ARTICLE NODESCRIPTIONLOCATIONLASTORDER
1Article 1102017-10-31
1Article 1112017-10-31
2Article 2202017-07-25
2Article 2212017-07-25
3Article 3302017-10-31
3Article 331

2017-10-31

4Unique Article 4322017-10-31

What I want is to show only article 4 because of its a unique article from the others. Any Idea how?

8 Replies
devarasu07
Master II
Master II

Hi,

location or ID causing the issue.

may try like this or remove the location field from your query.

Article:

LOAD *,

RowNo() as "ROW_Article",

DAY(LASTORDER)      AS "DAY",

MONTH(LASTORDER)    AS "MONTH", 

YEAR(LASTORDER)      AS "YEAR" ;

SQL

SELECT Distinct 

DESCRIPTION, 

EXTERNALIDENTIFIER AS ARTICLENO, 

LASTORDER 

FROM MATERIAL;

woshua5550
Creator III
Creator III

try get rid of "LOCATION" ,because it's different row by row

madhumitha
Creator
Creator

Hello Fadi,

You have use "count(Description)=1 " in the where clause, with the group by of all the other fields.

Distinct would just reduce the duplicates and does not give you the one time occurance.

Thanks!

Anonymous
Not applicable
Author

Hello and thanks for your answer,

This is my tree layout. This is where I am getting my data (ID or Location) from

qlikview-sql-unique article.png

Anonymous
Not applicable
Author

How I want to solve this is something like this:

  1. Article is in Location 1
  2. Location 1 is broken because of service
  3. I choose the location in QV
  4. The target location will show me the unique articles that isnt in the other locations and there is only in location 1.
  5. Hide all other articles.
effinty2112
Master
Master

Hi Fadi,

Maybe something like this after loading your article table

TempTable:

Load

ARTICLEID,

Count(ARTICLEID) as Cnt

Resident Article Group by ARTICLEID;

Inner Join(Article)

Load ARTICLEID Resident TempTable WHERE Cnt = 1;

DROP TABLE TempTable;

Good luck

Andrew

Anonymous
Not applicable
Author

I tried that too but it just gave me the same results.

  1. Article is in Location 1
  2. Location 1 is broken because of service
  3. I choose the location in QV
  4. The target location will show me the unique articles that isnt in the other locations and there is only in location 1.
  5. Hide all other articles.
Anonymous
Not applicable
Author

I fixed it with

  COUNT(DISTINCT SUBSTR(LOC.NAME,1,6)) OVER (PARTITION BY M.EXTERNALIDENTIFIER) AS SRM_USED