cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Measure for Inverse of Filter?

I am analysing Contacts who have visited certain Pages (Touchpoints) in a website. Of all the pages of the site, I have 3 that I want to analyse in a filter. These 3 pages are in a separate table. From the Filter of pages I want to create the following measures:

 

  1. Contacts who have visited pages selected by the Filter
  2. Contacts who have visited pages NOT selected by the filter

The table structure is straightforward:

 

Filter Touchpoint.PNG

 

I have managed to create the Measure 'Visited Selected' which is correctly showing contacts who have Events for the selected filters (A) & (C) as shown below, however I can't seem to get the Measure for 'Visited Non-Selected' working.

 

filter image.PNG

 

 

The code I have written for the measure to count contacts who have visited '(B) Player' is below however it is returning 0:

 

Visited Non-Selected = 

var selected = values( '_Filter Touchpoint'[Touchpoint] )
var allTouchpoint = all( '_Filter Touchpoint'[Touchpoint] )
var notSelected = EXCEPT( allTouchpoint , selected )

var distinctContact = GROUPBY(
        ADDCOLUMNS(
                filter(
                        GROUPBY(  
                                Event               
                                , Event[Contact Key]
                                , Event[Touchpoint Key]                                
                        )
                        , Event[Touchpoint Key] in notSelected
                )
                , "Event Count" , 1
        )
        , Event[Contact Key]
        , "Total Events" , SUMX( CURRENTGROUP() , [Event Count] )
)

return if( SUMX( distinctContact , [Total Events] ) = [Filter Count] , SUMX( distinctContact , [Total Events] ) , 0 )

Either this code needs some tweaking or a need a very different approach. Can anyone help?

 

Thanks

1 REPLY 1
Super User IV
Super User IV

Take a look at my Inverse Aggregator Quick Measure here:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Inverse-Aggregator/m-p/342266

 


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors