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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
user35131
Helper III
Helper III

I want to assign a flag if a group meets the criteria 3 times.

Currently my code works if it meets one of the 3 choices at least once.  If the group (Identifier) has at least "Row1","Row2","Row3" at least once it will be flagged. The adjustment I want to make is if the group has "Row1","Row2", and "Row3" filled.

Flag = 
VAR Flag1 = 
CALCULATE(
    COUNTROWS('Identifier Table'),
    FILTER('Identifier Table','Identifier Table'[Identifier]=EARLIER('Identifier Table'[Identifier]) && 'Identifier'[Identifier] IN { "Row1","Row2","Row3"}
    )
)
RETURN
IF(Flag1 >0 , "Flag", "No Flag")

 

 

Currently 

 

IDCol1Flag
1Row2Yes
1Row2Yes
1Row1Yes
2Row3Yes
2Row2Yes
2Row1Yes
3Row1Yes
4Row4No

 

I want the table to look like this 

 

 

IDCol1Flag
1Row2No
1Row2No
1Row1No
2Row3Yes
2Row2Yes
2Row1Yes
3Row1No
4Row4No
1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @user35131,

I'd like to suggest you add values function to remove duplicate values from the table at first, then you can use this list to get the unique item count of specific items to return flag:

NewFlag =
VAR _list =
    CALCULATETABLE (
        VALUES ( 'Table'[Col1] ),
        FILTER (
            ALL ( 'Table' ),
            [ID] = EARLIER ( 'Table'[ID] )
                && [Col1] IN { "Row1", "Row2", "Row3" }
        )
    )
RETURN
    IF ( COUNTROWS ( _list ) = 3, "Yes", "No" )

1.PNG

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

HI @user35131,

I'd like to suggest you add values function to remove duplicate values from the table at first, then you can use this list to get the unique item count of specific items to return flag:

NewFlag =
VAR _list =
    CALCULATETABLE (
        VALUES ( 'Table'[Col1] ),
        FILTER (
            ALL ( 'Table' ),
            [ID] = EARLIER ( 'Table'[ID] )
                && [Col1] IN { "Row1", "Row2", "Row3" }
        )
    )
RETURN
    IF ( COUNTROWS ( _list ) = 3, "Yes", "No" )

1.PNG

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors