Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Community
I am developing a dashboard (App). With fields : "Date", "Movement type", "Quantity", "Value"
I want to have a formula scenario allow me to select which column will be sum :
=Sum({$<[=MonthName(Date)]={"$(=MonthName(Addmonths(Date(Today()-1),0)))"}>} Getselected field)
By Getselected field, I would like to have a button that will allow me to switch between metrics : "Quantity" or "Value"
Thank you in advance.
Christian
hi
use variable buton in qlik sense
create a variable using the variable panel give it a name as vButton and give it 1 as value :
clik on create new variable
then add variable buton in your page :
under variable name select the vButton name :
add values : click on add alternative :
Value =1
Name = Value
clik on add alternative : and repeat for
Value = 2
Name = Quantity
Then add a variable with for example vSwith in the variable creation panel
and add this mesure
if(vButton =1 , 'Value', 'Quantity') :
In your mesure :
=Sum({$<[=MonthName(Date)]={"$(=MonthName(Addmonths(Date(Today()-1),0)))"}>} $(vSwitch))
create this in Variable and put in Set Analysis
VariableName=MonthName(Addmonths(Date(Today()-1),0))
and MonthName(Date) as MonthName in Script;
then
Sum({$<MonthName={"$(vAriableName"}>} Getselected field)
Sum({$<MonthName={'$(vAriableName'}>} Getselected field)
Thanks brunobertels
Firstly, thanks a lot for your answer.
I followed correctly steps by steps .
My last formula is :
=Sum({$<[=MonthName(CREMVTDAT_0)]={"$(=MonthName(Addmonths(Date(Today()-1),0)))"}>}$(vSwitch))
But, Error Message is :
"Error in expression : Sum takes 1 parameter"
Have you an idea ?
regards,
its due to this Variable $(vSwitch)
Sum({$<[=MonthName(CREMVTDAT_0)]={"$(=MonthName(Addmonths(Date(Today()-1),0)))"}>} $(vSwitch))
why when you use 1 inplace of $(vSwitch).its howing expresion Ok
Sum({$<[=MonthName(CREMVTDAT_0)]={"$(=MonthName(Addmonths(Date(Today()-1),0)))"}>} 1) showing correct
So check this $(vSwitch) . Here you have issue.
Hi
I think u test it by removing the equal sign in your variable or if u have try removing it
save it and check
sometime variable may give problem based on the output
Thanks and Regards
Kashyap.R
Hi
vSwitch is attempting to send either "Value" or "Quantity" as name dimension in your mesure Sum()
let's try to right directly the mesures in the variable vSwtich like that
if(vButton =1 ,
Sum({$<[=MonthName(Date)]={"$(=MonthName(Addmonths(Date(Today()-1),0)))"}>} Value),
if(vButotn= 2,
Sum({$<[=MonthName(Date)]={"$(=MonthName(Addmonths(Date(Today()-1),0)))"}>} Quantity)
))
where Value and Quantity are the dimension
Regards