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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
powerbi_bi
Frequent Visitor

Create a FLAG column with 1 or 0

Hi,

I have a table

IDCASE_IDCOUNTRY
1AAAUSA
1AAAJAPAN
1AAACHINA
2BBBCHINA
2BBBCHINA
2BBBCHINA
2BBBCHINA
3CCCUSA
3CCCJAPAN

 

I want to create a FLAG (Calculated_Column) with 1 or 0 based on the conditions

 

IDCASE_IDCOUNTRYCALCULATED_COLUMN
1AAAUSA1
1AAAJAPAN1
1AAACHINA1
2BBBCHINA0
2BBBCHINA0
2BBBCHINA0
2BBBCHINA0
3CCCUSA1
3CCCJAPAN1

 

The condition is:

If one CASE_ID has more than one country assigned then its 1 else 0

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

@powerbi_bi This should work Smiley Happy

 

Flag Column =
IF (
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[COUNTRY] ),
        ALLEXCEPT ( 'Table', 'Table'[CASE_ID] )
    )
        = 1,
    0,
    1
)

2010-10-04 - Conditional Column.png

 

View solution in original post

3 REPLIES 3
Sean
Community Champion
Community Champion

@powerbi_bi This should work Smiley Happy

 

Flag Column =
IF (
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[COUNTRY] ),
        ALLEXCEPT ( 'Table', 'Table'[CASE_ID] )
    )
        = 1,
    0,
    1
)

2010-10-04 - Conditional Column.png

 

I have a similar question based on the same data. How does the calculation change if I want my flag column to indicate whether a case has a CHINA value? Do I need a filter value in the DISTINCTCOUNT function?

 

My use case is that I want to see all countries for cases that have a CHINA value. Thanks!

Thanks Sean for the quick reply
Works Great!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors