Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Khushi
Frequent Visitor

PowerBI Slicing the data on multiple columns values

IN POwerbi we have data like 

MonThYearIDSuburbStreetAreaZoneCity
Jun 20231yesno no no no
Jun 20232yesyes no no no
Jun 20233 noyesyesyes no
Jun 20234 no no no no no

I have a slicer  with values

Suburb
Street
Area
Zone
City
NOne
  • IF Suburb is selected it should return row number 1
  • IF Suburb and street both are  selected it should return row number 1 and row number 2 and row number 3
  • IF area and street both are  selected it should return row number 2 and row number 3
  • and IF NOne is selected it should return row number 4

Now i have to map this on StackBar chart with Month Year on X Axis and Count on Y axis

1 ACCEPTED SOLUTION
Khushi
Frequent Visitor

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)

View solution in original post

3 REPLIES 3
Khushi
Frequent Visitor

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)

amitchandak
Super User
Super User

@Khushi , Better to unpivot this data and then create a measure with values yes and slicer with attribute

 

countrows(filter(Table, Table[Value] = "Yes" ))

 

Unpivot Data(Power Query): https://youtu.be/2HjkBtxSM0g

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Actually it is combination of two table

IDSuburbStreetAreaZoneCity
1yesno no no no
2yesyes no no no
3 noyesyesyes no
4 no no no no no
Id IdName
1A
2B
3C
4D

and the data is coming from AAS and this table is used at many place so i cann't pivot.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.