I have a number of projects in a database and queries based all around this.
As part of those queries I have the concept of EarliestProject and LatestProject. At this point in time these are provided by a query that pretty much contains just this.
MinDate = List.Min(CoreDataQuery[ProjectStartDate])
Now this works and I can just refer to it as EarliestDate in the other queries and it is good. The downside though is that it shows a one field query to the base data users. They should not need to see this.
In other areas I use Parameters, but these are not dynamic so cannot work for me above. I hit on the idea of a single Parameter table that carries a number of these. i.e. I can build a table with "Name","Value" where Name=EarliestProject and value = List.Min(CoreDataQuery[ProjectStartDate]). Ideally I'd like to then access this still using a VariableReplacement name i.e.
if [CurrentDate] < EarliestDate then.....
The above forces me to something more like
if [CurrentDate] < Table.SelectRows(ParameterData, each (Values[Name] = ""Earliest Project"")){0}[Value]
To solve this I decided I would create a Power Query function something like
FunctionName () => blah blah........
I could not get the syntax to resolve though and I suspect that you cannot create a parameterless function. Is that right? and if so what is the best way to build these uber variables? I could obviously create a function like GetParameter("EarliestProject") which would be quite flexible but still a little less clean. How do other people organise things like this?