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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Runnymede
New Member

Dynamic slicer based on text

I have the following data in table "Departments":

 

Month    Qty    Tags
------------------------- Sep 8 IT,HR Oct 3 HR Nov 4 IT,HR,PM

I have a second table "Tags", as follows:

 

Tags
-----
HR
IT
PM

I'm trying to represent the sum of Qty in a column chart, using a slicer populated by the rows in the Tags column. For example,

 

  • Select "IT" in the slicer, the column in the chart would show: 12   (Sep's 8 + Nov's 4)
  • Select "HR" in the slicer, the column would show: 15   (Sep's 8 + Oct's 3 + Nov's 4)
  • Select "PM" in the slicer, the column would show: 4   (Nov's 4)
  • Select "IT" and "HR" in the slicer, the column would show: 15   (Sep's 8 + Oct's 3 + Nov's 4)
  • Select "IT" AND "PM" in the slicer, the column would show: 12  (Sep's 8 + Nov's 4)
  • Select "HR" AND "PM" in the slicer, the column would show: 15   (Sep's 8 + Oct's 3 + Nov's 4)
  • Select "IT" AND "HR" AND "PM" in the slicer, the column would show: 15   (Sep's 8 + Oct's 3 + Nov's 4)

This is a simplified representation.

 

I have no idea how to achieve this. Any help would be greatly appreciated.

 

Thanks.

 

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @Runnymede ,

 

Firstly, you may enter into Query Editor, split the original Tags column, then Unpivot the result Tags columns ,remove Attribute column, rename the value column as Tags.

 

45.png46.png

 

 

 

 

 

 

 

Secondly, you can create measure like DAX below, put the measure onto Card visual.

 

 

Sum Qty = var _table=SUMMARIZE(Departments,Departments[Month],"d",CALCULATE(DISTINCT(Departments[Qty]),FILTER(Departments,Departments[Month]=MAX(Departments[Month]))))
return SUMX(_table,[d])

47.png

 

 

 

 

 

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

View solution in original post

3 REPLIES 3
v-xicai
Community Support
Community Support

Hi  @Runnymede ,

 

Does that make sense? If so, kindly mark my answer as a solution to help others having the similar issue and close the case. If not,  let me know and I'll try to help you further.

 

Best regards

Amy

v-xicai
Community Support
Community Support

Hi @Runnymede ,

 

Firstly, you may enter into Query Editor, split the original Tags column, then Unpivot the result Tags columns ,remove Attribute column, rename the value column as Tags.

 

45.png46.png

 

 

 

 

 

 

 

Secondly, you can create measure like DAX below, put the measure onto Card visual.

 

 

Sum Qty = var _table=SUMMARIZE(Departments,Departments[Month],"d",CALCULATE(DISTINCT(Departments[Qty]),FILTER(Departments,Departments[Month]=MAX(Departments[Month]))))
return SUMX(_table,[d])

47.png

 

 

 

 

 

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

Greg_Deckler
Super User
Super User

I am sure that I could code this up for a measure that you could use to include/exclude items in your visual. However, I feel like you would be better served if in Power Query you split out your last column by your comma delimiter and unpivoted the resulting columns. Then you could relate the two tables together and at that point what you are attempting to do becomes trivial with no code involved.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.