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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Conditional Measure

Hi,

 

I'm working with data set containing survey results. Instead a single row containing a user’s response to each question within the survey, each question has its own row for each user (example below). While measures and conditional columns have been created for simple stats, the structure is making it difficult, for me at least, to create a measure where the Answer from two or more questions, associated with a given user, meet a defined condition.

 

Example:

Using the table below as a reference, I need a measure that will count the number of users who have answered ‘No’ to ‘Have you attended before?’ but have then answered ‘Yes’ to ‘Did you attend this time?’ Based on the table below, the measure would return a result of '2' users.

 

The purpose is to track how many users have not attended a previous event but, as the result of a marketing campaign, have chosen to attend the current event.

 

I’d normally use a simple Advanced Filter option to set an AND condition but as the Answers aren’t contained within the single row, I need to associate multiple responses/rows (presumably by UserID) to different questions. Hope that makes sense.


Any help would be appreciated. Thanks

 

UserID

Name

Question

Answer

1212

Paul Smith

Had you attended before?

No

1212

Paul Smith

Did you attend this time?

Yes

1251

Julie Jones

Had you attended before?

Yes

1251

Julie Jones

Did you attend this time?

No

1271

Kelly Kid

Had you attended before?

No

1271

Kelly Kid

Did you attend this time?

Yes

6 REPLIES 6
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Based on my test, the solution provided by Zubair_Muhammad can return correct result. Please see below screenshot. 

1.PNG

 

Have you worked it out? If it doesn't meet your request, what is your desired output? Please post an image to illustrate your requirement.

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous

 

Please see the file attached here as well.

 

You can run these Formulas with a bigger data set to test

Zubair_Muhammad
Community Champion
Community Champion

Hi @Anonymous

 

Please try this measure

 

Measure =
COUNTROWS (
    FILTER (
        SUMMARIZE (
            TableName,
            TableName[Name],
            "RESULT", IF (
                AND (
                    CALCULATE (
                        VALUES ( TableName[Answer] ),
                        FILTER ( TableName, TableName[Question] = "Did you attend this time?" )
                    )
                        = "YES",
                    CALCULATE (
                        VALUES ( TableName[Answer] ),
                        FILTER ( TableName, TableName[Question] = "Had you attended before?" )
                    )
                        = "NO"
                ),
                "Success",
                "Nope"
            )
        ),
        [RESULT] = "Success"
    )
)
Anonymous
Not applicable

Hi Zubair,

 

Thanks for your reply. I'm not sure that measure is returning a count of when both conditions have been met. At least that's how I'm reading it. 

 

 

Hi @Anonymous

 

Also you can get a table of names of those persons who met these conditions

 

Go to Modelling Tab and select NEW TABLE

 

New Table =
FILTER (
    SUMMARIZE (
        TableName,
        TableName[Name],
        "RESULT", IF (
            AND (
                CALCULATE (
                    VALUES ( TableName[Answer] ),
                    FILTER ( TableName, TableName[Question] = "Did you attend this time?" )
                )
                    = "YES",
                CALCULATE (
                    VALUES ( TableName[Answer] ),
                    FILTER ( TableName, TableName[Question] = "Had you attended before?" )
                )
                    = "NO"
            ),
            "Success",
            "Nope"
        )
    ),
    [RESULT] = "Success"
)

If I understood correctly, you want to know unique employee who attended before and/or this time

 

add a simple measure 

 

Attended Answer = Calculate(DistinctCount(Survey[Name]), Filter(Survey, Survey[Answer] = "Yes"))

In table add question and this new measure, you will get the count, add slicer on the question to see the count of question you are interested in



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.