Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
mstoler
Partner - Specialist
Partner - Specialist

on demand workaround for varialble values not passed in

Hello,

Does anyone have a good workaround for on demand and variables not being passed in.

As an example in my dashboard I have a variable vUnitsDollars which is set to 0 for Units and 1 for dollars.  In my expressions I use:

if(vUnitsDollars=0,sum(Units),sum(NetAmount)

I then have a variable switch where the user can select units or dollars. This works great in Qlik Sense but this is not passed into on demand.

I know I can use a data island but how do I create a toggle switch that will change the values of the data island and then pass this to the variables.

Thanks in advance.

 

Michael

Labels (2)
3 Solutions

Accepted Solutions
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

As a follow up to your question about hiding selection - sure there is no issue with that, but there is a catch...

If you are going to use buttons like in my example with 2 blue buttons you have to configure them before you hide fields, because this object allows to configure only visible fields. To configure hidden fields you would have to edit object in Developer mode (aka with url suffix "/options/developer"
 --> right click --> Developer and manually edit properties of such object) which may not be worth an effort. 

So all what you do is configure objects while fields are still visible and when you are happy with results add that line to your script " TAG FIELDS UnitDollar WITH $hidden ;"  and reload to hide field:

Lech_Miszkiewicz_0-1634862855992.png

this is the result you would get - I dont know how to get rid of "hidden selection applied" message though, I reckon it needs to stay there:

Lech_Miszkiewicz_1-1634862984176.gif

 

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.

View solution in original post

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

regarding hiding fields - yes - there are multiple methods:

https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/SystemVariab...

or 

https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/SystemVariab...

or mention earlier: 

https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptRegula...

 

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.

View solution in original post

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Correct & Correct, that is exactly how it works.

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.

View solution in original post

15 Replies
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Michael,

what do you mean by saying: "but how do I create a toggle switch that will change the values of the data island and then pass this to the variables"

What problems are you facing?

This is my workflow:

  1. create toggle in script (On that occasion i also added variable definition which reads from field - that would work for your example like plug&play as long as you remove from your app all variable input objects/buttons which can override that variable definition)
    • Lech_Miszkiewicz_0-1634856432148.png

       

  2. Load data and set field properties to always one selected value
    • Lech_Miszkiewicz_1-1634856497479.png

       

  3. Use any form of filter pane for selections to be applied (I am using filter pane and table chart to show how variable changes, so it could be used just like you are using it now)
    • Lech_Miszkiewicz_2-1634856967435.gif

       

Am I missing something here?

Obviously the object you will be using to toggle (filter pane, native buttons with actions select in field or other....) that is up to you. 

Principle is the same: you have island table, you make it always one selected values and you use expression in variable to read that value. 

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
mstoler
Partner - Specialist
Partner - Specialist
Author

Hello,

Is there a way to do this so that the field does not show up in the filters at the top?

I want to make the transition from the variable (which I use the variable input) to a field look the same for the users.

 

Thanks,

 

Michael

 

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @mstoler 

I forgot to mention 2 important things:

  1. Always one selected value is not supported in NPrinting so for NPrinting I would have app which binary loads from the users app, but would have always one selected value removed from fields properties
  2. or if you dont want to manage 2 apps you need to think about workarounds. Example:
    • Instead of using toggle - use buttons with actions
    • variable uses expression which returns value if nothing is selected (aka default)
      • Lech_Miszkiewicz_3-1634860663425.png

         

      • Lech_Miszkiewicz_4-1634862171279.png

         

Obviously using second option requires a lot more work: creating button for each value, then if you want to make it looking nicer you would have to write expressions to capture what is current selection and based on that likely to apply colour on buttons which would indicate what is selected (or if nothing is selected then default state).

But all above is simple QlikView/Qlik Sense work we all were doing for years, so nothing new there.

 

cheers

Lech

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

As a follow up to your question about hiding selection - sure there is no issue with that, but there is a catch...

If you are going to use buttons like in my example with 2 blue buttons you have to configure them before you hide fields, because this object allows to configure only visible fields. To configure hidden fields you would have to edit object in Developer mode (aka with url suffix "/options/developer"
 --> right click --> Developer and manually edit properties of such object) which may not be worth an effort. 

So all what you do is configure objects while fields are still visible and when you are happy with results add that line to your script " TAG FIELDS UnitDollar WITH $hidden ;"  and reload to hide field:

Lech_Miszkiewicz_0-1634862855992.png

this is the result you would get - I dont know how to get rid of "hidden selection applied" message though, I reckon it needs to stay there:

Lech_Miszkiewicz_1-1634862984176.gif

 

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
mstoler
Partner - Specialist
Partner - Specialist
Author

Thanks,

And also I can use a default bookmark to assign an initial default value.

I assume the tag fields with $hidden is similar to the set HidePrefix='_' ;

Thanks again!

 

Michael

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

I would not use default bookmark-it may not be supported by nprinting. Similar to triggers in QlikView
I am not 100% sure about it, but i had issues with it in the past. 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
mstoler
Partner - Specialist
Partner - Specialist
Author

Hello,

If I can't use default bookmarks then how can I set the default value of the field?

Michael

 

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

you dont,

you can make variable to always set to one default value even if nothing is selected - just like i did. Using Max() or Min() returns only one value right?

I mentioned that in my previous comment already:

Lech_Miszkiewicz_0-1634911130621.png

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

regarding hiding fields - yes - there are multiple methods:

https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/SystemVariab...

or 

https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/SystemVariab...

or mention earlier: 

https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptRegula...

 

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.