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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
daniellf
Frequent Visitor

New column based on 3 others

I'm summarizing the results of a survey and need to exclude results from part of the population.

 

Considering the example table below, I'd like to create a column in the table which will indicate that an employee's answers should be excluded from the analysis if they did not answer a, b and c at least once(no matter what question). In the below, only John's answers would be considered valid.

 

How can I create this column 'Valid' keeping in mind that I have 15k unique employees.

 

 

EmployeeQuestionAnswerValid
Anna1ano
Anna2ano
Anna3ano
Anna4ano
Anna5bno
Anna6ano
John1ayes
John2byes
John3cyes
John4cyes
John5cyes
John6cyes
Blake1cno
Blake2bno
Blake3cno
Blake4bno
Blake5cno
Blake6bno
1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @daniellf ,

 

If the "a,b,c" means all the answer, we can use following DAX to meet your requirement.

 

V = 
VAR e = [Employee]
VAR result =
    COUNTROWS (
        DISTINCT (
            SELECTCOLUMNS ( FILTER ( Table1, 'Table1'[Employee] = e ), "A", [Answer] )
        )
    )
RETURN
    IF ( result = 3, "yes", "no" )

number 3 means the answer number

 

4.PNG

 

BTW, pbix as attached.

 

Best regards,

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

Community Support Team _ Dong Li
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

2 REPLIES 2
v-lid-msft
Community Support
Community Support

Hi @daniellf ,

 

If the "a,b,c" means all the answer, we can use following DAX to meet your requirement.

 

V = 
VAR e = [Employee]
VAR result =
    COUNTROWS (
        DISTINCT (
            SELECTCOLUMNS ( FILTER ( Table1, 'Table1'[Employee] = e ), "A", [Answer] )
        )
    )
RETURN
    IF ( result = 3, "yes", "no" )

number 3 means the answer number

 

4.PNG

 

BTW, pbix as attached.

 

Best regards,

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

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
SteveCampbell
Memorable Member
Memorable Member

 

Valid =
VAR _AnswerString = "a,b,c"
VAR _emplID = SELECTEDVALUE ( 'YourTable'[Employee] )
RETURN
    IF (
        CONCATENATEX (
            CALCULATETABLE (VALUES ( 'YourTable'[Answer] ), 'YourTable'[Employee] = _emplID),
            'YourTable'[Answer],"," ) 
= _AnswerString, "Yes","No" )

 

You can change the VAR _AnswerString = "" to be a list of accepted answers, separated by commas

 

 

Love hearing about Power BI tips, jobs and news?
I love to share about these - connect with me!

Stay up to date on  linkedin-logo.png
Read my blogs on  powerbi.tips_.png



Did I answer your question? Mark my post as a solution! Proud to be a Super User!


Connect with me!
Stay up to date on  
Read my blogs on  



Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.