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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
sonaliverma
Advocate I
Advocate I

How to create a flag measure in powerbi

Hello,

 

I have this column in powerbi:

 

DiscussionEvents

1. Discussion Created

2. Discussion Reply Created

3. Discussion Updated

4. Discussion Viewed

 

I am trying to create a flag measure that returns me 1 if the count of "Discussion Created" and "Discussion Reply Created" is not zero and vice versa.

 

Could anyone help please.

1 ACCEPTED SOLUTION

Hi @sonaliverma ,

 

Please try the following formula:

 

Measure = 
VAR count_created =
    CALCULATE (
        COUNT ( 'Table'[DiscussionEvents] ),
        'Table'[DiscussionEvents] = "Discussion Created"
    )
VAR count_reply =
    CALCULATE (
        COUNT ( 'Table'[DiscussionEvents] ),
        'Table'[DiscussionEvents] = "Discussion Reply Created"
    )
VAR flag =
    IF ( count_created > 0 && count_reply > 0, "YES", "NO" )
RETURN
    IF (
        ISFILTERED ( 'Table'[DiscussionEvents] ),
        COUNT ( 'Table'[DiscussionEvents] ),
        flag
    )

 

Then modify the total label: "Flag".

 

vkkfmsft_0-1651036617149.png  vkkfmsft_1-1651036670373.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

3 REPLIES 3
sonaliverma
Advocate I
Advocate I

Hello @nvprasad ,

 

Thank you for your response. Actually I am trying to build a Matrix with below columns:

 

DiscussionEvents

1. Discussion Created

2. Discussion Reply Created

3. Discussion Updated

4. Discussion Viewed

 

DiscussionID

1. 4256

2. 5619

3. 8916

etc. etc.

 

I am trying to create a pivot table like this:

 

DiscussionID    Discussion Created    Discussion Replied      Flag

1234                         1                                                             NO

4567                         2                                1                           YES

5678                         6                                4                           YES

5691                                                           1                           NO

 

POV: Values in discussion created and discussion replied is the count(DiscussionEvents).

 

 

 

Hi @sonaliverma ,

 

Please try the following formula:

 

Measure = 
VAR count_created =
    CALCULATE (
        COUNT ( 'Table'[DiscussionEvents] ),
        'Table'[DiscussionEvents] = "Discussion Created"
    )
VAR count_reply =
    CALCULATE (
        COUNT ( 'Table'[DiscussionEvents] ),
        'Table'[DiscussionEvents] = "Discussion Reply Created"
    )
VAR flag =
    IF ( count_created > 0 && count_reply > 0, "YES", "NO" )
RETURN
    IF (
        ISFILTERED ( 'Table'[DiscussionEvents] ),
        COUNT ( 'Table'[DiscussionEvents] ),
        flag
    )

 

Then modify the total label: "Flag".

 

vkkfmsft_0-1651036617149.png  vkkfmsft_1-1651036670373.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

nvprasad
Solution Sage
Solution Sage

Hi sonaliverma,

 

Can you try below measure.

 

Check = if (CALCULATE(COUNTROWS(TABLE),TABLE[COLUMN]="Discussion Created" ||TABLE[COLUMN]="Discussion Reply Created")>0, "YES","NO")

 

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

 

Did I answer your question? Mark my post as a solution! Appreciate your Kudos.
Follow me on LinkedIn.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors