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
user35131
Helper III
Helper III

Using DAX I want to create a flag off of a group if a specific value in another column appears once.

I would like to flag a group if only 7 in value appears once.

GroupValue
A7
A2
A3
B8
B9
C7
C5
C7
D7

 

 

I would like it to look like. Note that only D has 7 appear once. It is the only acceptable outcome. 

 

GroupValueResult
A7N
A2N
A3N
B8N
B9N
C7N
C5N
C7N
D7Y
1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @user35131 

Here are the steps you can refer to :
[1]If you want to add a calculated column in table , you can click "New Column" and enter:

Column = var _flag =7
var _count_flag = CALCULATE( COUNT('Table'[Value]) ,'Table'[Value]=_flag,ALLEXCEPT('Table','Table'[Group]))
var _count_total = CALCULATE( COUNT('Table'[Value]) ,ALLEXCEPT('Table','Table'[Group]))
return
IF(_count_flag=1 && _count_total=1,"Y","N")

vyueyunzhmsft_1-1675822242556.png

 

 

[2]If you want to add a measure on the visual , you can click "New Measure" and enter this:

Measure = var _flag =7
var _cur_group=MAX('Table'[Group])
var _count_flag =COUNTROWS( FILTER(ALLSELECTED('Table') , 'Table'[Group] = _cur_group && 'Table'[Value]=_flag))
var _count_total =COUNTROWS( FILTER( ALLSELECTED('Table')  , 'Table'[Group] =_cur_group))
return
IF(_count_flag=1 && _count_total=1 ,"Y","N")

vyueyunzhmsft_0-1675822231323.png

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

View solution in original post

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi , @user35131 

Here are the steps you can refer to :
[1]If you want to add a calculated column in table , you can click "New Column" and enter:

Column = var _flag =7
var _count_flag = CALCULATE( COUNT('Table'[Value]) ,'Table'[Value]=_flag,ALLEXCEPT('Table','Table'[Group]))
var _count_total = CALCULATE( COUNT('Table'[Value]) ,ALLEXCEPT('Table','Table'[Group]))
return
IF(_count_flag=1 && _count_total=1,"Y","N")

vyueyunzhmsft_1-1675822242556.png

 

 

[2]If you want to add a measure on the visual , you can click "New Measure" and enter this:

Measure = var _flag =7
var _cur_group=MAX('Table'[Group])
var _count_flag =COUNTROWS( FILTER(ALLSELECTED('Table') , 'Table'[Group] = _cur_group && 'Table'[Value]=_flag))
var _count_total =COUNTROWS( FILTER( ALLSELECTED('Table')  , 'Table'[Group] =_cur_group))
return
IF(_count_flag=1 && _count_total=1 ,"Y","N")

vyueyunzhmsft_0-1675822231323.png

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

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.