Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
joey_lutes
Partner - Creator
Partner - Creator

Toggle Flag Display

I have what I think should be a simple task, but for some reason is defeating me.

In my table, there are items that periodically need to be upgraded - on a date.

Item     Upgrade

1           10/10/2016

2         

3           11/04/2016

As you'll notice, there are 3 items, 2 needing upgrades.  I have created a flag (UpgradeFlag) in the script = 1, 0

What I want to do is to show charts/graphs where either UpgradeFlag=1, OR All.  (meaning a user can see metrics based on all items, or just those needing upgrades)

Sounds so simple!

Variables?

Thanks in advance!

1 Solution

Accepted Solutions
joey_lutes
Partner - Creator
Partner - Creator
Author

After scouring the Internet and lots of trial and error, I came up with the answer and wanted to share.

For Charts/Graphs, the following expression works:

if($(vUpgrade)=1, count({$<UpgradeFlag = {'1'}>}distinct Item), count(distinct Item))


For a straight table, the expression that works is:

if($(vUpgrade)=1, aggr(if(UpgradeFlag=1, Item), Item), Item)

View solution in original post

7 Replies
sunny_talwar

I would use the a variable assigned to a button to toggle between 1 and 0 and then the variable can be used like this:

If(vVar = 1, If(UpgradeFlag = 1, Upgrade), Upgrade)

So now when vVar = 1, you will see Upgarde Needed Items and When vVar = 0, you will see all items

joey_lutes
Partner - Creator
Partner - Creator
Author

Thanks Sunny.  I think I'm missing a piece.

Is this something I could set in the script or?

I'm considering using a Branch Extension  - either way, vVar is set as a variable, and toggled as 1 or 0 by user.

I was hoping to end up with a set analysis expression in all my elements perhaps?

For example:

Dimension:  Item

Measure:  Count({$<$(vVar) = {$(vVar)}>} Items)

I would need that 'if' statement to be present somewhere however, thereby setting the condition.  Just not sure where to put it.

Also, would you mind explaining why it works? 

vinieme12
Champion III
Champion III

Why not a Dual Flag

if(Your Condition , (DUAL('Upgrade needed',1) , DUAL('Upgrade not needed',2)) as UpgradeFlag

and Add the UpgradeFlag Field as List box to filter on

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
joey_lutes
Partner - Creator
Partner - Creator
Author

thanks Vineeth - I thought of that, but I don't need to know 'not needed' - just 'needed'/'flagged'  or 'all. 

Still having trouble figuring out exactly how to show that effectively.

joey_lutes
Partner - Creator
Partner - Creator
Author

Just to clarify, my intent is to have a toggle button on the dashboard that says 'Upgrades Only'

If it's toggled to 'on', then only items needing upgrade will show, if 'off', then all items will show.

This would affect every element on the dashboard - graphs, charts and tables.

While I believe Sunny's solution would work, I'm not sure exactly where to implement it. 

So if there was a table like this when the button was 'off':

Item     Upgrade

1           10/10/2016

2        

3           11/04/2016

And the user clicked the button 'on', the following table would change to display:

Item     Upgrade

1           10/10/2016

3           11/04/2016

I've employed this Qlik Branchsolution, which seems to work well.  I have the variable vUpgrade set, and it toggles 1 and 0 appropriately.  I need a way to map vUpgrade=1 = UpgradeFlag=1, while vUpgrade=0 = UpgradeFlag 1 AND 0 (or just [item], either way)

Thanks!

joey_lutes
Partner - Creator
Partner - Creator
Author

While not necessarily as effective as I'd hoped, I did discover an answer for this for charts/KPIs.

if($(vUpgrade)=1, count({$<UpgradeFlag = {'1'}>}distinct Item), count(distinct Item))

Still working on the one for a table.  What I have currently is not really working as designed:

if($(vUpgrade)=1, Only({$<UpgradeFlag = {'1'}>}Item), Item)

It does change the table a bit, but not quite the way I was hoping.

Still open to better ideas.

Thank you.

joey_lutes
Partner - Creator
Partner - Creator
Author

After scouring the Internet and lots of trial and error, I came up with the answer and wanted to share.

For Charts/Graphs, the following expression works:

if($(vUpgrade)=1, count({$<UpgradeFlag = {'1'}>}distinct Item), count(distinct Item))


For a straight table, the expression that works is:

if($(vUpgrade)=1, aggr(if(UpgradeFlag=1, Item), Item), Item)