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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kimberlyrose1x
Frequent Visitor

Returning a different value based on duplicates

Hello, all...I am thankful you exist. 🙂

 

Here is my issue:

 

I am trying to do a pie chart that compares number of arrests where a mental health flag is present vs. when it is not.

 

I have duplicate rows if the arrest was for a person who had more than one type of flag.

 

Currently, I am using Count(Distinct) in the visualization filter so that an arrest is only considered once, however, it is counting one "Yes" and one "No" for each arrest number.

 

What I am looking for is a way in DAX to have the first instance of a duplicate that meets a condition say 'Yes' and any following values be blank if they are the same arrest number. That way I can filter out the blank values.

 

I currently have a simple IF statement: IF(table[column] = "MH", "Yes", "No") which returns: 

Arrest #FlagMH Flag
1MHYes
1HXSNo
1FELNo
2FELNo
3HXSNo

 

I would like a DAX expression that returns the following based on the duplicate arrest numbers (Thank you so much in advance!):

 

Arrest #FlagMH Flag
1MHYes
1HXS(Blank)
1FEL(Blank)
2FELNo
3HXSNo
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @kimberlyrose1x 

Please try

MH Flag =
IF (
"MH"
IN CALCULATETABLE (
VALUES ( 'Table'[Flag] ),
ALLEXCEPT ( 'Table', 'Table'[Asset #] )
),
IF ( 'Table'[Flag] = "MH", "Yes" ),
"No"
)

View solution in original post

2 REPLIES 2
kimberlyrose1x
Frequent Visitor

tamerj1,

 

You are a genius beyond measure. It worked. Thank you so much!!

 

Crystal

tamerj1
Super User
Super User

Hi @kimberlyrose1x 

Please try

MH Flag =
IF (
"MH"
IN CALCULATETABLE (
VALUES ( 'Table'[Flag] ),
ALLEXCEPT ( 'Table', 'Table'[Asset #] )
),
IF ( 'Table'[Flag] = "MH", "Yes" ),
"No"
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors