cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AGS94
Resolver I
Resolver I

Distinct, Filter, Nested IFs

I am failry new to PA, so bear with me, but I am trying to get Distinct to work in conjunction with the following formula:

 

 

Filter
   (PtAColl,
       //The "No"s in the following are not actually in the data table (only "Yes"s are and anything not "Yes" is blank), but they serve the purpose of not returning the respective column if/when the control is not seleted
       If(ChkInt.Value=true,"Yes","No") in Interior || If(ChkExt.Value=true,"Yes","No") in Exterior,
       If(ChkClr.Value=true,"Yes","No") in Clear || If(ChkSol.Value=true,"Yes","No") in Solid || If(ChkOth.Value=true,"Yes","No") in Other
   )

 

 

To this point the formula is doing what I would expect it to do (resulting data output below), but I can't get Distinct to work.

 

I have tried a handful of ways and I can structure such that no errors, blue lines, etc. are returned, but no matter how I have tried to format it, the output is alwasy blank.

 

The data source is PtAColl and the formula above is being entered into DataTable1.items. I would like to make the ProdFam column distinct.

 

Thanks in advance. Would also ultimately like to Sort ProdFam too, but would be happy to just get Distinct to work at this point.

 

Capture.JPG

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

When you use Distinct the result column is called "Result". If you go the table fields property you will see a field called "Result". Make sure that is checked so it shows in the table and that column should display the ProdFam distinct values.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

6 REPLIES 6
Jeff_Thorpe
Super User
Super User

Distinct returns a single column table. If you use Distinct on ProdFam then that is the only column that will be returned and displayed in your table. 

 

Example: Distinct( PtAColl, ProdFam)



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Actually that is exactly what I ultimately want. What do I need to do to display the single column table just so I can make sure things are working properly as I continue to flesh out this formula?

Thanks for the help and quick response!

Just add "Distinct( PtAColl, ProdFam)" to the items property of the data table.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

Understood, but I need to run the nested Ifs and Filter prior to running Distinct in order to get the results I need. That said, no matter how I try entering the Distinct, I cannot get it to show any data. So, for example, when I modify the previous formula (which is in the items property of the data table) as follows:

 

Distinct(
Filter
   (PtAColl,
       //The "No"s in the following are not actually in the data table (only "Yes"s are and anything not "Yes" is blank), but they serve the purpose of not returning the respective column if/when the control is not seleted
       If(ChkInt.Value=true,"Yes","No") in Interior || If(ChkExt.Value=true,"Yes","No") in Exterior,
       If(ChkClr.Value=true,"Yes","No") in Clear || If(ChkSol.Value=true,"Yes","No") in Solid || If(ChkOth.Value=true,"Yes","No") in Other
   ),
ProdFam)

I will not get any errors, blue lines, etc. but following is what my table shows. So prior to adding Distinct, the Filter/If commands are working as expected, but Distinct, Filter, Ifs are not playing nice with each other.

 

Capture.JPG

 

When you use Distinct the result column is called "Result". If you go the table fields property you will see a field called "Result". Make sure that is checked so it shows in the table and that column should display the ProdFam distinct values.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

Did not realize that. Thanks for all of your help.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,305)