Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Creating a key and counting

I am trying to create a key based on the following fields:

Screen Shot 2016-01-20 at 01.48.31.png

I need a key based on the [Script Number] and Branch.  Where the [Script Number] and the Branch make a unique key, this should generate the same key for example [Script Number] 102356 and Branch [First] should generate the same key for the same combination.  I would then want a count of this key, something like the following:

[Distinct Script Data]:
BUFFER LOAD [Script Number],
AutoNumber([Script Number], [Branch]) as Script#,
Count Script# as Rx
Group by
[Script Number];
SQL SELECT DISTINCT
    "Script Number"
FROM PharmaMarketAudit.dbo.tblDatawarehouseConsolidatedCleanStage
WHERE
[Date Dispensed] >= '2012-01-01' and [Date Dispensed] <= '2015-08-31';


How can this be accomplished?

Regards

2 Replies
jagan
Luminary Alumni
Luminary Alumni

HI,

Try like this

[Distinct Script Data]:
BUFFER LOAD [Script Number],
AutoNumber([Script Number] & [Branch]) as Script#,
Count Script# as Rx
Group by
[Script Number];
SQL SELECT DISTINCT
    "Script Number"
FROM PharmaMarketAudit.dbo.tblDatawarehouseConsolidatedCleanStage
WHERE
[Date Dispensed] >= '2012-01-01' and [Date Dispensed] <= '2015-08-31';


Regards,

Jagan.

Anonymous
Not applicable
Author

Thanks Jagan, i will try it out and advise accordingly.

Regards.