Forum Discussion
Recreate field parameter logic with Calculation group/table/columns
Hi everyone,
We used Field Parameters to dynamically add and remove one or more measures as columns in a table visual, but since these parameters are in the backend calculated tables, they are not supported with DirectQuery in the cloud, we need to find a different solution for this.
If for instance I have a calculation group named "Measures" and it has two calculation items, one being "Revenue" and the other "Budget". When dragging the calculation group into a table visual I immediately get both measures added as 2 columns, so it seems that the calculation group could be the way to replace the field parameter, but I am stuck in trying to find a way to slice the calculation group in such a way that I can add or remove calculation items to the table visual.
Currently I came up with the following, which does not work sufficiently yet:
I have a calculated table that has all the names of the measures I want to dynamically add or remove.
I have the following measures:
Selected Measures =
SELECTCOLUMNS(
FILTER(
VALUES('Table'[Measure]),
[Is Selected] = TRUE()
),
"Selected Measure", 'Table'[Measure]
)Selected Measure Value =
VAR SelectedMeasure = SELECTEDVALUE('Selected Measures'[Selected Measure])
RETURN
SWITCH(
SelectedMeasure,
"Omzet", [Omzet],
"Brutowinst", [Brutowinst],
"Bestelde hoeveelheid", [Bestelde hoeveelheid],
"Verkooporderregels (#)", [Verkooporderregels (#)],
BLANK()
)Dynamic Measure 1 =
VAR SelectedMeasures = 'Selected Measures'[Selected Measure]
RETURN
IF(
CONTAINSSTRING(SelectedMeasures, "Omzet"),
[Omzet],
BLANK()
)
Dynamic Measure 2 =
VAR SelectedMeasures = 'Selected Measures'[Selected Measure]
RETURN
IF(
CONTAINSSTRING(SelectedMeasures, "Brutowinst"),
[Brutowinst],
BLANK()
)This however not adds or removes columns, but it leaves them blank or filled whether selected or not.
Then I came up with the idea of creating a calculated table based on selected measures in a slicer, the following way:
DynamicTable =
IF (
NOT ISBLANK ( [Selected Measure] ),
SWITCH (
[Selected Measure],
"Omzet", SELECTCOLUMNS ( Fact, "Omzet", [Omzet] ),
"Brutowinst", SELECTCOLUMNS ( Fact, "Brutowinst", [Brutowinst] ),
"Bestelde hoeveelheid", SELECTCOLUMNS ( Fact, "Bestelde hoeveelheid", [Bestelde hoeveelheid] ),
"Verkooporderregels (#)", SELECTCOLUMNS ( Fact, "Verkooporderregels (#)", [Verkooporderregels (#)] ),
BLANK ()
),
BLANK ()
)However, in this way I already have to program inside this calculated table which fields from which dimensions I want to include.
What I want to do is reuse these measures in different table visuals. So for instance:
A table visual with Customers, then based on slicer add multiple measures, so for instance Revenue as a column, Budget as a column, or if both are selected, which means two columns should be added.
A table visual with Suppliers with also other information from the Supplier dimension, and again, dynamically add measure columns to this table.
This is all incredibly easy with Field Parameters, but there must be a way to recreate this just having Calculation Groups and Calculated Tables at your disposal, right?
Kind regards,
Igor
1 Reply
- jaryszekSuper User
Hi,
if this was solved?