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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
WJ_WJ
Regular Visitor

Count selected IDs with filtering removed

Hi,

 

Data like this: 

WJ_WJ_0-1700035867969.png

 

creates a matrix like this;

WJ_WJ_2-1699904044571.png

 

and when ckicked a table like this:

WJ_WJ_3-1699904168266.png

I want to create a measure that counts the IDs 2 or 3 for the different date and stage, so I can visualise it like this:

WJ_WJ_1-1700036016792.png

 

In DAX I can use the following code, but struggle how to define the VAR selected_ids dynamically. I tried to use VALUES on the [ID], but it selects alll the possible IDs. 

 

WJ_WJ_0-1700036798295.png

 

Thanx!

 

7 REPLIES 7
amitchandak
Super User
Super User

@WJ_WJ , Try if this solution can help

 

Power BI Partial Interactions, Selectively pass filter across visuals - https://youtu.be/SFEKQEic_sk

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

Thx for your reply, but Im looking for  a fully DAX solution. Should be possible...

Anonymous
Not applicable

I'm not sure why you'd always want just id 2 and 3, you could use a slicer for a dynamic selection but if you want it hardcoded try:

Test = 

VAR _table = FILTER('stagesTbl',

                                 'stagesTbl'[id] = 2 || 'stagesTbl'[id] = 3)

RETURN

COUNTX(_table, COUNT('stagesTbl'[id]))

Thx for the reply. I dont want it hard copied. An this is sample data, a slicer would show to much IDs in the real data. I tried to use the select all option for a slicer, but it selects all the know IDs, not only the one for a specific date and stage...

Anonymous
Not applicable

I'm a bit confused as that seemed to be what you were asking for in your original post? If you want to filter by date and stage can't you just add slicers for those?

The idea is that the orignal table gets filter by date and stage. For a specific date and stage, 1,2 of 3 row will get selected. The IDs in these row are unique. Now I want to visualise (count) the number of those IDs for each date and stage.

For example: the filter stage = 2 and month = August wil return 2 rows with ID 2 and 3. Now I want to count these IDs (2 or 3) for each stage and date, like: 

WJ_WJ_0-1700056530373.png

 

Anonymous
Not applicable

Hi, I created a sample data set based on the small table in your post. I created 2 disconnected tables based on that in order for this to work, see below:

TobyNye_0-1700058633799.png

TobyNye_1-1700058646934.png

 

I added these columns in to slicers adn then used the following measure: 

Conditional Filters =
VAR _stages = CONCATENATEX(VALUES(Stages[stage]), [stage], UNICHAR(10))
VAR _id_table = FILTER(ALL(Testing), CONTAINSSTRING(_stages, Testing[stage]) && Testing[date] >= MIN(Dates[date]) && Testing[date] <= MAX(Dates[date]))
VAR _id_string = CONCATENATEX(_id_table, [id], UNICHAR(10))
VAR _final =
 CALCULATE(DISTINCTCOUNT(Testing[id]), FILTER(Testing,
                                 CONTAINSSTRING(_id_string, Testing[id]))
            )
RETURN
_final
in order to achieve this result:
TobyNye_2-1700058697516.png

You can select multiple dates and stages and it should still work, I believe this is as you wanted. Let me know if you have any issues or further questions.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.