Forum Discussion

Khushi's avatar
Khushi
Frequent Visitor
2 years ago
Solved

PowerBI Slicing the data on multiple columns values

IN POwerbi we have data like  MonThYear ID Suburb Street Area Zone City Jun 2023 1 yes no  no  no  no Jun 2023 2 yes yes  no  no  no Jun 2023 3  no yes yes yes  n...
  • Khushi's avatar
    2 years ago

    Created below measure and it is working 


    VAR SelectedOptions =
    CONCATENATEX(
    ALLSELECTED('SlicerRequest-Selection'),
    'SlicerRequest-Selection'[MeasureName],
    ","
    )

    VAR SuburbRecords =
    CALCULATETABLE (
    'Table_Fact',

    CONTAINSSTRING(SelectedOptions, "Suburb") &&
    'Table_Fact'[Suburb]="Yes"
    )

    VAR streetRecords =
    CALCULATETABLE (
    'Table_Fact',
    CONTAINSSTRING(SelectedOptions, "street") &&
    'Table_Fact'[street] ="Yes"
    )


    VAR AreaRecords =
    CALCULATETABLE (
    'Table_Fact',
    CONTAINSSTRING(SelectedOptions, "Area") &&
    'Table_Fact'[Area] ="Yes"
    )

    VAR ZoneRecords =
    CALCULATETABLE (
    'Table_Fact',
    CONTAINSSTRING(SelectedOptions, "Zone") &&
    'Table_Fact'[Zone] ="Yes"
    )

     

    RETURN
    SUMX(DISTINCT( UNION (
    SELECTCOLUMNS(SuburbRecords, "Suburb",1,"ID",'Table_Fact'[ID]),
    SELECTCOLUMNS(streetRecords, "Street",1,"ID",'Table_Fact'[ID]),
    SELECTCOLUMNS(AreaRecords, "Area",1,"ID",'Table_Fact'[ID]),
    SELECTCOLUMNS(ZoneRecords, "Zone",1,"ID",'Table_Fact'[ID])
    )),1)