Forum Discussion

esingh's avatar
esingh
Icon for Helper I rankHelper I
1 year ago
Solved

filter selection as group in single visuals

Hi Community We have recieved a request to have following filter on a data set 1) Selected Company - User Choice 2) Company Cohort (Will be dynamically selected by User) 3) Classification of Comp...
  • grazitti_sapna's avatar
    grazitti_sapna
    1 year ago

    Hi esingh,

     

    Thanks for the clarification — since your Selected Company, Cohort, and Classification filters are coming from independent tables, the approach still works — you just need to make sure your DAX measure properly pulls selections from those disconnected filters and applies them against your main fact table via relationships or logic.

     

    Create Disconnected Comparison Group Table

    CompanyComparisonGroup =
    DATATABLE(
    "GroupType", STRING,
    {
    {"Selected Company"},
    {"Cohort"},
    {"Classification"},
    {"All Companies"}
    }
    )

     

    Create Your Metric Measure (Assuming measure Total Revenue)

    TotalRevenue = SUM('FactTable'[Revenue])

     

    Now define the unified logic using your disconnected slicers:

    CompanyGroupMeasure =
    VAR SelectedGroup = SELECTEDVALUE(CompanyComparisonGroup[GroupType])
    VAR SelectedCompany = SELECTEDVALUE('SelectedCompany'[CompanyName])
    VAR SelectedCohort = VALUES('Cohort'[CompanyName])
    VAR SelectedClass = VALUES('Classification'[CompanyName])

    RETURN
    SWITCH(
    TRUE(),
    SelectedGroup = "Selected Company",
    CALCULATE([TotalRevenue], 'FactTable'[CompanyName] = SelectedCompany),

    SelectedGroup = "Cohort",
    CALCULATE([TotalRevenue], 'FactTable'[CompanyName] IN SelectedCohort),

    SelectedGroup = "Classification",
    CALCULATE([TotalRevenue], 'FactTable'[CompanyName] IN SelectedClass),

    SelectedGroup = "All Companies",
    [TotalRevenue]
    )

     

     

    • Axis: CompanyComparisonGroup[GroupType]

    • Value: CompanyGroupMeasure

    • Optional Tooltip: Add [TotalRevenue] as well for raw value view