There are many times where I have to write complicated formulas that all do the same thing, but due to current constraints, it has to be done. For example:
Updating values in a viz
IF [Parameter] = 'Sales' THEN SUM([Sales])
ELSEIF [Parameter] = 'Discount' THEN AVG([Discount])
Or using it to format text
IF [Parameter] = 'Sales' THEN '$' + STR([Calculation to Format Sales Dynamically])
ELSEIF [Parameter] = 'Discount' THEN STR(AVG([Discount])) + '%'
This is a tiring and non-dynamic way to build calculations that doesn't always allow growth for business use cases and leaves room for errors.
To solve for this comes FIELDNAME()
This calculation would require a variable to be added in the parenthesis AND would inherit the default values of the field it's mimicking (aggregation, format, etc). This is where Parameter Actions really come into play:
- Have a list of Measure Names in the dashboard
- Create a calculated field using FIELDNAME([Parameter])
- Use that in another viz to display whatever view someone could be interested in to update
- Custom scatter plots, line charts, etc