Forum Discussion

Quartarolo's avatar
Quartarolo
Regular Visitor
5 years ago
Solved

How to show missing values from a reference based on a key from an answer

Hi Everyone.

 

I'm kind of new to Power BI, but i've been working hard on a report these days.

 

My problem is: I have a fix reference table and an answers table (based on a key) shown bellow

 

'Reference'

 

Fixed Answers

A

B

C

D

E

 

'Answers'

Key

Answer

1

A

1

C

2

A

2

D

3

B

 

What I'm trying to do is get the following table:

 

'Final I want'

Key

Missing answer

1

B,D,E

2

B,C,E

3

A,C,D,E

 

Either on separated rows or in the same cell works for me, but I just can't seem to get it...

 

I even get a list of missing values, but not related to the key. what I got was:

 

'Table I got'

Missing Answers

E

 

Can anyone help?

  • Hi Quartarolo 

    0. Change the name of the Reference[Fixed Answers] column to Reference[Answer]

    1. Place Answers[Key] in the a table visual

    2. Create this measure and place it on the visual

    Missing answer =
    VAR answers_ =
        DISTINCT ( Answers[Answer] )
    VAR refAnswers_ =
        ALL ( Reference[Answer] )
    VAR missing_ =
        EXCEPT ( refAnswers_, answers_ )
    RETURN
        CONCATENATEX ( missing_, [Answer], ", " )

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers 

3 Replies

  • AlB's avatar
    AlB
    Community Champion

    Hi Quartarolo 

    0. Change the name of the Reference[Fixed Answers] column to Reference[Answer]

    1. Place Answers[Key] in the a table visual

    2. Create this measure and place it on the visual

    Missing answer =
    VAR answers_ =
        DISTINCT ( Answers[Answer] )
    VAR refAnswers_ =
        ALL ( Reference[Answer] )
    VAR missing_ =
        EXCEPT ( refAnswers_, answers_ )
    RETURN
        CONCATENATEX ( missing_, [Answer], ", " )

    Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

    Contact me privately for support with any larger-scale BI needs, tutoring, etc.

    Cheers 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Quartarolo  - Sorry your question is not clear to me.

    Can you please explain what's the logic applied for 'Final I want' ?

     

    All i understand is There is a reference table with values A to E

    'Answers' table? What does this mean? How A and C has the same key value 1? And A and D has 2

    Totally confusing to me

     

    Please be more elaborative.

     

    Cheers,

    -Namish B

    • Quartarolo's avatar
      Quartarolo
      Regular Visitor

      Sorry, it's my first post! I'll elaborate more:

       

      the 'Answers' table is from a form filled by my costumer. In there, they choose a location (the 'key" column), and choose a safety item that was installed (those are the answers).

       

      The thing is that not all items are installed at the same time, so there is more than one row for each location.

       

      I'll rewritte the tables:

       

      'Reference'

      Safety Item

      A

      B

      C

      D

      E

       

      'Costumer Answers'

      Key (Location)

      Answer (Safety Item installed)

      1

      A

      1

      C

      2

      A

      2

      D

      3

      B

       

      So what i want to know is "which items haven't been installed on each location"

       

      If it's still confusing, just let me know, and thanks for the help!