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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
PowerBITesting
Helper IV
Helper IV

Slicer value which filters comma separated data - Matrix Report

I cant spilts the Account ( activty type ) column as there is relationship constriant is there. 

I have added Slicer as Activity Type Table which shows colour . How I can filter the Account table for the Slicer with If (Contains) value.

 

I was trying something like 

measureFilterActivity  

VAR selectedActivity = SELECTEDVALUE('Activity Type'[ID]) 

return  

CALCULATE([measure_Total], 

Filter(All(Account),  

SEARCH(100, Account[Activity Type],,BLANK())>0 

|| SEARCH(101, Account[Activity Type],,BLANK())>0 ........

)) 

But this dint worked for me .

 

 

Capture.JPG

13 REPLIES 13
Anonymous
Not applicable

Hi @PowerBITesting ,

According to my understanding, you want to calculate the total when the value of Activity Type contains slicers selected value, right?

 

You could use the following formula:

totalMeasure =
VAR _selected =
    SELECTEDVALUE ( 'Activity Type'[ID] )
RETURN
    IF (
        CONTAINSSTRING ( SELECTEDVALUE ( Account[Activity Type] ), _selected ),
        1,
        0
    )

// Apply Conditional formatting

backColor =
VAR _selected =
    SELECTEDVALUE ( 'Activity Type'[ID] )
VAR _selectedColor =
    CALCULATE (
        SELECTEDVALUE ( 'Activity Type'[Color] ),
        FILTER ( ALL ( 'Activity Type' ), 'Activity Type'[ID] = _selected )
    )
RETURN
    IF (
        CONTAINSSTRING ( SELECTEDVALUE ( Account[Activity Type] ), _selected ),
        _selectedColor,
        "White"
    )

My visualization looks like this:

8.24.3.1.png

Is the result what you want? If you have any questions, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best Regards,

Eyelyn Qin

Hi @Anonymous ,

 

I have followed the same steps but no success, Might be I am doing wrong .

Attaching Power Bi file below. 

Demo One.PBIX 

amitchandak
Super User
Super User

@PowerBITesting , Try like

measureFilterActivity =  
VAR selectedActivity = SELECTEDVALUE('Activity Type'[ID]) 
return  
CALCULATE([measure_Total], 
Filter(All(Account),  Account[Activity Type], selectedActivity
))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Fowmy
Super User
Super User

@PowerBITesting 

Can you try this measure, you select multiple codes as well

 

 

measureFilterActivity = 

VAR selectedActivity = ALLSELECTED(Activity[Code]) 
var _sum = 
SUMX(
    VALUES(Accounts[Activity Type]),
    IF(
    COUNTROWS(
        FILTER(
            selectedActivity,
            SEARCH(Activity[Code],Accounts[Activity Type],,0) > 0
        )
    ) >0, CALCULATE(SUM(Accounts[Value]))
    )
)
RETURN

_sum

 

 

Fowmy_0-1598215594201.png

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube, LinkedIn

?


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

HI @Fowmy I have added your measure but no success. 

I have attched my PBIX file in another reply. 

Please try this expression.  It should work with multiple selections on the Color slicer (with no relationship between the tables). 

 

Color Filter Count =
SUMX (
VALUES ( Color[Activity Type Code] ),
VAR thiscode = Color[Activity Type Code]
RETURN
COUNTROWS (
FILTER ( Activity, SEARCH ( thiscode, Activity[Activity Type],, 0 ) > 0 )
)
)

 

Also, is the relationship between the Account ID and Activity ID correct?  The activity appears to just be an index column.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@PowerBITesting 

 

I checked it, your initial question and the PBIX files do not match. 

Can explain exactly what you need to resolve?

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi @Fowmy  Account and Activity are 1:N related. Matrix shows account name , Created on date from activity, group by month/year. which shows the count of activity types(count color codes) for the respective account and activity( month/year -created on date from activity).

If I add a filter with contains that worked for me but I need same thing slicer should do. 

PowerBITesting_0-1598289863820.png

 

I need to filter by Color (only those activities) and total should be updated based on the Filter?

Download this copy( rectified few data sets). 

 

DemoOne.pbix 

Did you try the measure I suggested?  It return the same values as your example when White is selected (Activity = 100).

 

mahoneypat_0-1598291436633.png

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


HI @mahoneypat  

 

I have added the measure , no chnage. Do I need to add any filter?

 

PowerBITesting_0-1598292694892.png

 

I reopened your original file and just added the measure (to make sure I didn't do anything else too), and it worked the same.  I removed the count you had there and added the new measure, filtered on White and it worked.  Not sure why didn't work for you.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Perfect ! let me test in my desired data set and update you

 

PowerBITesting_0-1598295712467.png

 

One more thing If I dint select any slicer value  value count is wrong?

 

PowerBITesting_0-1598295887333.png

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.