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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register 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

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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