I want to display related fields based on what year I select. Let's say I have the said fields, named CG_2016, CG_2017, CG_2018, CG_2019, CG_2020. I have a dropdown of the said years, when I select 2020, I want to display the data for the fields, CG_2018, CG_2019, and CG 2020. I'm trying to do this in a gallery.
To illustrate:
If I choose 2020, my Gallery would look like this:
ThisItem.CG_2018 ThisItem.CG_2019 ThisItem.CG_2020
If I choose 2019, my gallery would look like this:
ThisItem.CG_2017 ThisItem.CG_2018 ThisItem.CG_2019
I know I can simply do this by using an if statement for the visibility but my data table is expected to grow through the years, thus I was wondering if there are other possible solutions. Please help and thank you in advance.
Solved! Go to Solution.
Hi @santoscp_mwci ,
If my understanding is correct, you are seeking a way to reference the column dynamically, e.g. Variable, right?
However, it is not supported in PowerApps currently, please vote for this existing idea .
You have to hardcode the column into the expression. If you want more streamlined code, I would suggest you try with Switch function, which is much simpler than If function.
Siwtch(DropdownName.Selected.Value, "2020", ThisItem.CG_2020, "2019", ThisItem.CG_2019)
Hope this helps.
Sik
Hi @santoscp_mwci ,
If my understanding is correct, you are seeking a way to reference the column dynamically, e.g. Variable, right?
However, it is not supported in PowerApps currently, please vote for this existing idea .
You have to hardcode the column into the expression. If you want more streamlined code, I would suggest you try with Switch function, which is much simpler than If function.
Siwtch(DropdownName.Selected.Value, "2020", ThisItem.CG_2020, "2019", ThisItem.CG_2019)
Hope this helps.
Sik