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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
moonpie100
Frequent Visitor

Is it possible to group columns together, and then filter by group?

Hello All.

 

First off, I am new to power BI, so please bear with me (I am hoping I have included all necessary information).

 

I have searched to see if there were previous questions asked that are similar to my question but looking at other solutions, these solutions did not seem to fit exactly what I was looking for.

 

The sample data I am working with is classes, and number of students who attended those classes, and dates attended(screenshot below).

 

attendance table.PNG

 

I was wondering if it was possible to group classes together, and then use the group as a slicer.

 

For example lets say class1 & class2 are math classes,  class3 and class4 are history classes, class5 and class6 are science classes.

 

I would then like to have a filter/slicer with options of math, history, science, so when when I select math, only class1 and class2 data are shown.

 

I am not sure if what I am wanting to do is possible.

 

 

Any help is appreciated.

 

Thank you in advance. 

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

 

Click on Edit Queries and right click on the first column > Unpivot Other columns.  Click on Add Column > Custom column and write this M formula there

 

=if [Attribute]="class1" or [Attribute]="class2" then "Maths Classes" else if [Attribute]="class3" or [Attribute]="class4" then "History Classes" else "Science classes"

 

Alternatively, after unpivoting, click on Close and Load.  Then go to Data Modelling and write this calculated column formula

 

=IF(OR([Attribute]="Class1",[Attribute]="Class2"),"Maths Classes",IF(OR([Attribute]="Class3",[Attribute]="Class4"),"History Classes","Science Classes"))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

 

Click on Edit Queries and right click on the first column > Unpivot Other columns.  Click on Add Column > Custom column and write this M formula there

 

=if [Attribute]="class1" or [Attribute]="class2" then "Maths Classes" else if [Attribute]="class3" or [Attribute]="class4" then "History Classes" else "Science classes"

 

Alternatively, after unpivoting, click on Close and Load.  Then go to Data Modelling and write this calculated column formula

 

=IF(OR([Attribute]="Class1",[Attribute]="Class2"),"Maths Classes",IF(OR([Attribute]="Class3",[Attribute]="Class4"),"History Classes","Science Classes"))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

THANK YOU THANK YOU THANK YOU!

 

This was exactly what I was looking for.

 

I appreciate your help and walking me through this. 

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.