Forum Discussion

PBI_VL's avatar
PBI_VL
Regular Visitor
3 months ago
Solved

Problem with field parameter and empty slicer

Hello,   I have a field parameter in my report:   Category Switch = {     ("Age", NAMEOF('Coverages'[AGE_CATEGORY]), 0),     ("Cover1", NAMEOF('Coverages'[COVER_AGE_CATEGORY]), 1),     ("Cove...
  • v-hashadapu's avatar
    v-hashadapu
    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.