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
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
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.