Auto AutoNumber your key fields

By Barry Harmsen

A quick note on a cool feature that I recently learned from Oleg Troyansky: AutoNumber.

I hear you thinking: “What? You didn’t know about AutoNumber? It’s been around for years. Hand over your Luminary badge!“. Admittedly, this is also what I thought when I hear Oleg mention it but it turned out that I misunderstood. Oleg wasn’t talking about the AutoNumber() script function, but the AutoNumber script statement. This statement was added in the June 2018 release of Qlik Sense (as well as QlikView 12.20) and lets you AutoNumber multiple fields, across multiple tables in a single line of script. And no, despite it being available for over a year, I hadn’t heard about it before. I’ll certainly be using it going forward though!

AutoAutoNumber

I’m sure that Oleg (or Rob) will discuss potential use cases and performance implications in a future blog post and that it will be touched upon in our Masters Summit for Qlik materials.

For now I just want to share a quick hack that I cooked up this Friday; AutoAutoNumber. If you call this subroutine at the end of your script, it will automatically discover all key fields in your data model and apply AutoNumber to them:

What I like about it is that you can easily check your keys during development/maintenance and don’t have to manually enable AutoNumbering when you’re getting the app ready for production. Also, when key fields are changed or added, they’ll be automatically picked up.

You can find the full subroutine here. I am very interested in hearing your opinions about it, and any potential improvements you may see.

Update: Youri Torchalski points out in the comments below, that you can also use a wildcard with the AutoNumber script statement. For example: AutoNumber “*_Key”; If you are using a consistent naming convention for your keys, and that is always a good idea, then you don’t need to use the subroutine. Thanks to Youri for pointing this out!

Now that you’re here

If these are the sort of tips and tricks you enjoy, then you’ll love the Masters Summit for Qlik. In 3 days, we’ll take your skills to the next level and help you get more from your investment in Qlik. We do this not only by training you, but also by providing you with a wealth of ready-made examples, tools, utilities and drop-in solutions that you can start using immediately. Additionally, with many Qlik enthusiasts there and ample opportunities to network, you will not only go home with new skills and ideas, but also with valuable new professional contacts.

We have events coming up in Amsterdam and Washington DC, currently still with an attractive $300 early-bird discount (ends October 4th 2019). See you there?

Masters Summit for Qlik - Amsterdam - Washington DC