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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Jesskim96
Frequent Visitor

Use a result of a distinct count measure as a filter

Hi,

 

I'm not sure it's possible, but I want to have the option to filter a card visualisation by the results of two distinct counts.

 

I have a data that includes an Customer ID and a Programme ID. Each Customer ID can have participated in multiple different programmes and so there is not a distinct list. I want to be able to show in a card how many customers particpated in more than 1 programme. I have tried using a calculated table but these are not impacted by slicers from the original data which I need within the report as I want this to be dynamic based on the slicer settings applied. 

 

This is an example of the original data

Jesskim96_0-1733327860616.png

This is the distinct count I want to do to get the number of programmes each customer has been involved in: 

Jesskim96_1-1733327913992.png

This is the ideal final format that I would want within Power BI or the ability to filter on one of the programmes within a card and just show the count of customer IDs.

Jesskim96_2-1733327959410.png

 

As I said, I'm not sure it's possible to do but any direction you can point me in would be great, thanks!

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You would need to create a table to store and show the number of programmes, you could use something like

Number of programmes = GENERATESERIES( 1, 5 )

You can then create a measure to show the number of customers who match that number of programmes

Num matching customers =
VAR CurrentNumberOfProgrammes =
    SELECTEDVALUE ( 'Number of programmes'[Value] )
VAR CustomersWithCount =
    ADDCOLUMNS (
        VALUES ( 'Table'[Customer ID] ),
        "@num programmes", CALCULATE ( DISTINCTCOUNT ( 'Table'[Programme ID] ) )
    )
VAR Result =
    COUNTROWS (
        FILTER ( CustomersWithCount, [@num programmes] = CurrentNumberOfProgrammes )
    )
RETURN
    Result

Put the measure in a visual with the column from number of programmes.

View solution in original post

3 REPLIES 3
Jesskim96
Frequent Visitor

That works thank you!

 

Following from this, is there a way to do the same but be able to then select only one of the Values in the Number of Programmes table within filters so I could show the Num matching customers in a card rather than a table? When I try to put it in a card the I get a blank value as I assume it needs the Values to work?

 

Thanks!

Add the Number of Programmes column into the filter pane for the card visual and choose which number you want

johnt75
Super User
Super User

You would need to create a table to store and show the number of programmes, you could use something like

Number of programmes = GENERATESERIES( 1, 5 )

You can then create a measure to show the number of customers who match that number of programmes

Num matching customers =
VAR CurrentNumberOfProgrammes =
    SELECTEDVALUE ( 'Number of programmes'[Value] )
VAR CustomersWithCount =
    ADDCOLUMNS (
        VALUES ( 'Table'[Customer ID] ),
        "@num programmes", CALCULATE ( DISTINCTCOUNT ( 'Table'[Programme ID] ) )
    )
VAR Result =
    COUNTROWS (
        FILTER ( CustomersWithCount, [@num programmes] = CurrentNumberOfProgrammes )
    )
RETURN
    Result

Put the measure in a visual with the column from number of programmes.

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!

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.

Top Solution Authors
Top Kudoed Authors