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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
HarryFries
New Member

Power query conditional column with complex conditions. Then remove rows that don't meet conditions.

I'm pulling survey results from a db where the dev who built the site will not fix an error where if the user clicks too fast, it records an answer from a previous question as the answer for the next. This gives me question results that shouldn't be possibe. 

 

I'm hoping to be able use a conditional column to remove the false results. 

 

So if column A(question) = Question Q1 AND Column B(answer) = Answer A1 OR A2 Then it can it stay. But if A = Q1  amd B= A3, then it has to go.... 

 

There are 6 questions, 

Q1 has A1 & A2 possible

Q2 has A3, A4, A5, & A6 possible

Q3 has A1 & A2 possible

Q4 has A1 & A2 possible

Q5 has A7, A8, A9, A10, A11, & A12 possible

Q6 has A13, A14, A15, A16, A17,A18 & A19 possible

Is this even possible to pull execute? 

1 REPLY 1
wdx223_Daniel
Community Champion
Community Champion

NewStep = Table.RemoveMatchingRows(
                                   PreviosStepName,
                                   {false},
                                   each if _ is logical then _ 
                                        else List.Contains(
                                                           {
                                                            {"Q1",{"A1","A2"}},
                                                            {"Q2",{"A3","A4","A5"}},
                                                            {"Q3",{"A1","A2"}},
                                                            {"Q4",{"A1","A2"}},
                                                            {"Q5",{"A7","A8","A9","A10","A11","A12"}},
                                                            {"Q6",{"A13","A14","A15","A16","A17","A18","A19"}}
                                                           },
                                                           _,
                                                          (x,y)=>x{0}=y[Question] and List.Contains(x{1},y[Answer])
                                                         )
                                      )

you can update that list to match you real data.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.