cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
danielcarpenter
Helper I
Helper I

How to find if matching value exists in another column of a dynamically filtered dataset

In plain english what I am trying to do is....

  1. Given a dynamically filtered dataset
  2. Take the parent id value for each row and search for a matching value in the issue id column of the filtered result set
  3. If the value is present in the filtered dataset then count the row; if not then do not count the row

Here is some sample data demonstrating the desired result and rationale

2020-11-16_10-05-33.jpg

And here is what I've created for DAX so far, but it is only identifing the parents rows and not identifying the child rows whose parent is in the filtered dataset.

 

parent in dataset = 
var parentlink = 
    IF(HASONEVALUE(table[parent_id]),MAX(table[parent_id]),"")
return
    COUNTX(
        FILTER(table,
        CONTAINS(ALLSELECTED(table),table[issue_id],parentlink)
        ),table[issue_id]
    )

 

 

Thanks in advance for your assistance!

1 ACCEPTED SOLUTION
danielcarpenter
Helper I
Helper I

I figured out this problem and sharing here

 

parent in dataset = 
//define epics as the basis for evaluation
var parent = VALUES(table[parent_id])

//defines logic for evaluating if epic is owned or not
var matches = 
    IF(
        CALCULATE(
            COUNTROWS(table),
            ALLSELECTED(),
            TREATAS(parent,table[issue_id])
        ),1,BLANK()
    )

return
//perform logic for each row in table
SUMX(table,matches)

 

View solution in original post

5 REPLIES 5
danielcarpenter
Helper I
Helper I

I figured out this problem and sharing here

 

parent in dataset = 
//define epics as the basis for evaluation
var parent = VALUES(table[parent_id])

//defines logic for evaluating if epic is owned or not
var matches = 
    IF(
        CALCULATE(
            COUNTROWS(table),
            ALLSELECTED(),
            TREATAS(parent,table[issue_id])
        ),1,BLANK()
    )

return
//perform logic for each row in table
SUMX(table,matches)

 

Can this be implemented as a measure? or only a calculated column?

The above formula is a measure. This use case cannot work as a calculated column as the dataset is filtered dynamically based on user filter selections. 

lbendlin
Super User
Super User

your ID-1525 row actually points to another scenario that you have not considered in your formula approach.

 

1. parent present and child(ren) present

2. child(ren) present but parent not present

3. parent present but no child(ren) present

 

You need to compute each scenario separately.

Rows like issue ID = ID-1525 (the parent rows) are the only rows working with my current formula. I haven't found an approach that identifies the children - navigating the row context to find matching values in different rows appears to be my challenge. 

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors