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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
juleshelen
New Member

DAX to compare data in different tables and return a response

Hi 

I have a data table that contains responses from a set of audit questions which have been answered multiple times by different users with yes/no answers. I then have a data table that has the expected correct answer for each question (examples below)

I want to be able to create a column in the audit data table that compares the response against the "expected response" and then returns either a true or false result dependent on if it matches. 

I am struggling to write the DAX for this can anyone help?

AUDIT DATA

questionaudit response
have all staff members had trainingyes
have all volunteers had trainingno
are all doors fitted with external locksno
have all staff members had trainingno
have all volunteers had trainingyes

Expected responses

questionexpected response
have all staff members had trainingyes
have all volunteers had trainingyes
are all doors fitted with external locksyes
1 ACCEPTED SOLUTION
BabyYoda
Frequent Visitor

Response Matches Expected Response = Var GetExpectedResponse = LOOKUPVALUE('Expected Response'[Expected Response], 'Expected Response'[Question],'Audit Data'[Question])
RETURN IF(GetExpectedResponse='Audit Data'[Audit Response], TRUE(), FALSE())

View solution in original post

3 REPLIES 3
BabyYoda
Frequent Visitor

Response Matches Expected Response = Var GetExpectedResponse = LOOKUPVALUE('Expected Response'[Expected Response], 'Expected Response'[Question],'Audit Data'[Question])
RETURN IF(GetExpectedResponse='Audit Data'[Audit Response], TRUE(), FALSE())

thank you that works perfectly

I wouldn't solve this with DAX.  I would join the two tables by the Question field.

 

Then, in Table, bring over Responder Name, Question and Audit Response from Audit table and Expected response from the Expected Response table.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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