Forum Discussion

Jared_Leonard's avatar
Jared_Leonard
Frequent Visitor
4 years ago

How to Produce Similar Filtering for Query that's too Complex

Hi all,

 

This is similar to a previous post I made, but because of my initial erros in formulating the power query, the old subject no longer applies. I am running into an issue where the query I have produced for my desired filtering works in Power Query, but when I try to transform data by using this query, Power BI tells me to use a simpler query. Unfortunately I don't know how I could simplify it to produce the same results.

 

The underlying table is in a Dataverse, and has the following structure: Every row of the table "responses" has a question, and answer, and an id. The table catalogs responses to a survey, and the id is not unique to each row, it is unique to every instance of a user taking a survey. So if a survey has 5 questions, and a user completes it, that id would appear 5 times in the table.

 

What I am trying to do with my query is this: Find every row where the answer has a particular value, say 'A'. Then, stick the id's of those rows into a list, and grab every row of responses that has an id in the list. This way, a user viewing the Power BI report could see every response which answered 'A' to a question.

 

The power query I've gotten so far is below:

let
    Source = CommonDataService.Database("my-dataverse.crm.dynamics.com"),
    dbo_responses = Source{[Schema="dbo",Item="responses"]}[Data],
    AList = Table.SelectRows(dbo_responses, each [answer] = "A")[id],
    AllAs = Table.SelectRows(dbo_responses, each List.Contains(AList, [id]))
in
    AllAs

This works in the preview, but when trying to  Apply & Close, I receive the following:

 

 

In what ways could I simplify this expression while producing the same results, or what can I tool can I use to produce similar filtering?

 

Thanks!

2 Replies

    • Jared_Leonard's avatar
      Jared_Leonard
      Frequent Visitor

      I believe that's correct. It selects every entry from the responses table having the desired answer value, and then just grabs a list of the "id"s having those answers.

      If you think this is the wrong way to do it, I am open to alternatives.