Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a list box with a set of values, calculated as year(Data_order). Data_order is a field name.
I want to use the year selected in this list box in an expression and I tried to use GetCurrentSelections. In order to see if it works I created a text box that display the result of GetCurrentSelections.
I don't have a field name with the year so I used GetCurrentSelections(year(Data_order)).
But it doesn't work: when I select a year in the list box (e.g 2007) in the text box it appears "Data_order: 318 of 1298" while I want to appear just "2007".
Where is the error?
Thanks,
Marco
Hi
First, the GetFieldSelections returns 318 of 1298 because that's how many dates it has selected when you clicked on 2007, to get the full list of what it has selected you need to change it to GetFieldSelections(Data_Order,9999) where 9999 is the maximum number of dates that "could" be selected.
This then brings the second problem, which is trying to get the year value out of those multiple selections, I would imagine that there is a way to achieve this using the Only() function but I've been playing around with it and can't figure it out.
This then leads me to believe that by far the easier option for you is to create the YearNumber field in the load script, that way, you don't need to bother about all this stuff, you just put the YearNumber into the list box and its done!
If the user selects a year in that list box, then year(Data_order) is the year they selected. You should be able to use that in an expression. GetCurrentSelections(...) isn't really what you want here. Probably isn't what you want even if you created a Year field (and I agree with Nigel that you should create a Year field).
Thanks! I tried loading directly year(Data_order).
Two things:
- how can I give it a name like YearOrder while loading it? Now the name of the field is year(Data_Order)
- now in the text box it appears: "year(Data_Order): 2007". Why not only "2007"? When in the expression I use the GetCurrentSelections I need the result to be the year in order to compare it to the year of another data field. Like :
sum(if(year(Data_payment)=GetCurrentSelections([year(Data-order)]),amount,0)). Now it doesn't work
1) year(Data_order) as Data_order_year
2a) What's your text box expression?
2b) sum({<Data_payment_year=Data_order_year>} amount)
2c) Not sure why you want to select one field, but make that selection affect another. I suspect data model or requirements issues, but I don't know enough to say for sure.
Thanks to all, I finally found a way to do it