Forum Discussion
Problem with field parameter and empty slicer
- 3 months ago
Hi PBI_VL , You cannot dynamically return a column directly from a measure, so use the disconnected table as the axis and then use TREATAS inside the measure to apply the correct column filter. For example, create a disconnected table that contains all category values from both columns, like:
AxisTable =
DISTINCT(
UNION(
SELECTCOLUMNS(Coverages, "Category", Coverages[AGE_CATEGORY]),
SELECTCOLUMNS(Coverages, "Category", Coverages[COVER_AGE_CATEGORY])
)
)Then use AxisTable[Category] on the Y axis and create a measure like:
ClientCount Dynamic =
VAR CoverSelected =
ISFILTERED(DimCover[Cover])
RETURN
IF(
CoverSelected,
CALCULATE(
[ClientCount],
TREATAS(VALUES(AxisTable[Category]), Coverages[COVER_AGE_CATEGORY])
),
CALCULATE(
[ClientCount],
TREATAS(VALUES(AxisTable[Category]), Coverages[AGE_CATEGORY])
)
)With this setup, when no Cover is selected the axis behaves like AGE_CATEGORY and when a Cover is selected it behaves like COVER_AGE_CATEGORY. You also avoid the unstable behaviour caused by the field parameter.
Workaround:
Add a separate "None" option to the parameter.
Use a blank measure or blank column for that option.
Set that as the default state.
- PBI_VL3 months agoRegular Visitor
How can I set a default state?
I have a table Coverages
For example
clientid/covercd/age/age_category/cover_age_category
1 - Cover1 - 17 - 11-20 - 0-24
2 - Cover1 - 32 - 31-40 - 25-44
3 - Cover1 - 55 - 51-60 - 45-64I have a table DimCover
For example
Cover1
Cover2
Cover3I have the field parameter with a relationship between table DimCover and the field parameter.
The slicer is on DimCover.
When nothing is selected on the slicer I want to have the age_category in the Y as.
When a cover is selected on the slicer I want to have the cover_age_category in the Y as.