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

Make DISTINCTCOUNT Measure ignore slicer

I have a table with multiple entries per user. Each entry represents an event (though that info is not relevant for this question).

user_idfilter
12330
123180
35530
35560
49090

 

The filter column determines if the event was sent X or less days ago. That is:

  1. 30 if the event was sent 30 or less days ago
  2. 60 if the event was sent between 31 and 60 days ago
  3. 90 if the event was sent between 61 and 90 days ago
  4. 60 if the event was sent between 91 and 180 days ago

I use this column as a Slicer to allow the user to select certain periods of time.

I made the following measure to count the number of users that have logged at least one event in the last X days (based on the value that the user sets the slicer to):

events_filtered = DISTINCTCOUNT(my_table[user_id])

I now want to create a measure that is not affected by the slicer. That is, a distinct count that ignores the slicer.
At first, I thought I could modify the interactions. However, I want to display both measures in a Multi-row card visual. Hence, how can I create a measure that calculates the grand total of the unique users in the table?
1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hey @arturos ,

 

you can ignore a slicer with the ALL function. This function you can use as a context modifier in the CALCULATE function.

So the following approach should give you the result you want:

events_filtered =
CALCULATE (
    DISTINCTCOUNT ( my_table[user_id] ),
    ALL ( filter_Table[filter] )
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic

View solution in original post

1 REPLY 1
selimovd
Super User
Super User

Hey @arturos ,

 

you can ignore a slicer with the ALL function. This function you can use as a context modifier in the CALCULATE function.

So the following approach should give you the result you want:

events_filtered =
CALCULATE (
    DISTINCTCOUNT ( my_table[user_id] ),
    ALL ( filter_Table[filter] )
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic

Helpful resources

Announcements
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

Thank you 2022 Review

2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.