Below is where I had a situation where I wanted to put in a parameter within a piece of text. This was so that I could then dynamically change the Month Version for my budget and when I refreshed my data it would then use my specific Month Version. This was due to the requirement being that they wanted the ability to select ANY Month Budget Version.
- I had a requirement where I wanted to use a parameter value, but it would form part of a complete part of text. And as shown below in this example it would be for Mar (March)
I wanted the Output to look like the following:
- And the part which is part of the variable is highlighted in BLUE above “Mar“
I also wanted to re-use this for multiple conditions later in my script.
I required it for the following:
- CY – This is for the Current Year
- YR1 – This is for the following Year 1, so if I am in 2016 it would be for Year 2017
- YR2 – This is for the following Year 2, so if I am in 2016 it would be for Year 2018
- YR3 – This is for the following Year 3, so if I am in 2016 it would be for Year 2019
In order to do this, I went into the Advanced Editor in the Query Editor.
The name of my Parameter was called “Budget Version“, so when using it in the Advanced Editor it would be used with the following syntax below.
In the section below is where I now defined by additional conditions, so that they would be dynamic. An explanation will follow afterwards.
BudgetVersionCY = “Budget_”&#” Budget Version”&“_CY”,
BudgetVersionYR1 = “Budget_”&#” Budget Version”&”_YR1″,
BudgetVersionYR2= ” Budget _”&#” Budget Version”&”_ YR2″,
BudgetVersionYR3= ” Budget _”&#” Budget Version”&”_ YR3″,
As you can see above each line was compromised of the following:
I defined our name highlighted in RED
Then I started with what our name was, which is highlighted in BLUE
Next is where I inserted our Parameter highlighted in PURPLE
- &#” Budget Version”&
- NOTE: When you want to add additional TEXT or parameters you have to open it with the ampersand “&” as well as close it off (or end it) with an ampersand “&” also.
And then finally I added some more text at the end highlighted in BLUE again.
Then later in my query is where I put in my conditional statements into my Conditional Column as shown below.
#”Filtered Rows” = Table.SelectRows(#”Added Custom2″, each ([Budget Version] = #”
BudgetVersionCY” or [Budget Version] = #” BudgetVersionYR1” or [Budget Version] = #” BudgetVersionYR2” or [Budget Version] = #” BudgetVersionY3“)),
Just one thing to note, is when I put in the following syntax into my Query Editor you will lose the capability to edit it by using the settings or Gear icon