Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
In Qlik Sense, I have a variable called vCost that I would like to display as currency. In other words, if a user inputs 31, I would like the box to update to read:
$31.00
Is there any way to do that?
Also, is there a way to do validation on a variable input? In other words, if a user put the word 'Amazing' in the vCost input box, I would like the system to reject the input and clear the box.
My thanks for any ideas.
I guess you have another place where the output is.
So just add '$' & $(vCost ) in the output variable in the other box
For Q2 you can use isnum() function so only numerical value will be taken into account and other rejected.
The closest thing you can probably get to is to have the Variable Input be set to display as a Drop down and either manually enter or create an expression that will generate list of values that users can select. Something like this:
The users will then be able to select a cost from the list:
It's not an ideal user experience, but might work if the amount of values that user should be able to select is limited.
As for the input data type validation, that also isn't available. But, what you can potentially do is have the input box "communicate" to user when an invalid value is populated.
For example, have the background of the input box turn red when a user inputs a value that is not a number and maybe a footer note telling them to enter a number instead. Something like this:
Hi @timwhite
Without getting in to hacking Sense by injecting JavaScript, I don't think you are going to be able to alter the contents of the variable input box, but you can certainly change it wherever that value is displayed.
Wherever you display the value in the variable, wrap it in a num function, which formats the value:
=num(vCost, '$#,##0.00')
This will add the dollar sign to the front, add two decimal places and thousand separators (just use $0.00 to not have the separators).
The other good thing about this function is that it returns null if the value passed is not a number. In a chart this will give you a value you can then suppress.
If you want to get rid of the "-" that appears for nulls you can extend the expression to:
=if(isnum(vCost),'',num(vCost, '$#,##0.00'))
Hope that helps,
Steve