Forum Discussion

PowerBITesting's avatar
6 years ago

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 .

 

 

13 Replies

  • 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

     

     

    ________________________

    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

    ?


    • PowerBITesting's avatar
      PowerBITesting
      Icon for Helper IV rankHelper IV

      HI Fowmy I have added your measure but no success. 

      I have attched my PBIX file in another reply. 

      • Fowmy's avatar
        Fowmy
        Icon for Super User rankSuper User

        PowerBITesting 

         

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

        Can explain exactly what you need to resolve?

         

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi PowerBITesting ,

    According to my understanding, you want to calculate the total when the value of Activity Type contains slicer’s 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:

    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

    • PowerBITesting's avatar
      PowerBITesting
      Icon for Helper IV rankHelper IV

      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 

  • PowerBITesting , Try like

    measureFilterActivity =  
    VAR selectedActivity = SELECTEDVALUE('Activity Type'[ID]) 
    return  
    CALCULATE([measure_Total], 
    Filter(All(Account),  Account[Activity Type], selectedActivity
    ))