cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BauwensER3
Frequent Visitor

Incompatible types for comparison when comparing collection values with dropdown selection

I have the following piece of code on the OnSelect when users click on a button to generate a report:

 

GeneratePDFProject.Run(User().Email,
JSON(
Filter(
'Projects',
colViews.ViewName = Dropdown.Selected.ViewName

),
IgnoreUnsupportedTypes & JSONFormat.IgnoreBinaryData
)
);

 

my Dropdown contains several collection values like 'my projects', ' all projects', etc... now I want to be able based upon the selection made in the Dropdown to produce  a report that is filtered based upon the selection.  

 

When I hoover over the = sign I keep on getting the following error message:

 

Incompatible types for comparison. These types can't be compared: Table, Text.

 

Appreciate any advise or solution for this. Thanks!

 

 

 

 

 

8 REPLIES 8
PG_WorXz10
Resident Rockstar
Resident Rockstar

Hi @BauwensER3 ,

 

To get deeper into this issue would you please explain colViews.ViewName in your code. What this colViews.ViewName contains and is the ViewName column present in Projects ?

 

Thanks 

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

On the OnStart of the application I have the following piece of code:

 

ClearCollect(
colViews,

{
ViewName: "My Projects",
ViewColumns: [
"ID",
"Title",
"Requested by Section",
"Point of Contact in Section",
"Location of Work",
"Brief description of the work",
"Requested Start Date",
"Estimated End Date",
"Approval Status"
]
},

{
ViewName: "All Projects",
ViewColumns: [
"ID",
"Title",
"Requested by Section",
"Point of Contact in Section",
"Location of Work",
"Brief description of the work",
"Requested Start Date",
"Estimated End Date",
"Approval Status"
]
},

{
ViewName: "Pending Approval",
ViewColumns: [
"ID",
"Title",
"Requested by Section",
"Point of Contact in Section",
"Location of Work",
"Brief description of the work",
"Requested Start Date",
"Estimated End Date",
"Approval Status"
]
},

{
ViewName: "Approved by MGT",
ViewColumns: [
"ID",
"Title",
"Requested by Section",
"Point of Contact in Section",
"Location of Work",
"Brief description of the work",
"Requested Start Date",
"Estimated End Date",
"Approval Status"
]
},

);
Set(varSortColumn,"ID");
Set(varSortDirection,Descending);
Navigate(HomeScreen)

 

 

For my datatable on Items I have the following code:

 

Switch(
Dropdown.Selected.ViewName,
"My Projects",
SortByColumns(
Filter(
'Projects',
StartsWith(
Title,
SearchBox.Text
) && 'Created By'.Email = User().Email || StartsWith(
'Brief description of the work',
SearchBox.Text
) && 'Created By'.Email = User().Email || StartsWith(
'Location of Work',
SearchBox.Text
) && 'Created By'.Email = User().Email
),
varSortColumn,
varSortDirection
),
"All Projects",
SortByColumns(
Search(
'Projects',
SearchBox.Text,
"Title",
"Briefdescriptionofthework",
"LocationofWork"
),
varSortColumn,
varSortDirection
),
"Pending Approval",
SortByColumns(
Filter(
'Projects',
StartsWith(
Title,
SearchBox.Text

) && 'Approval Status' = "Pending Approval"
),
varSortColumn,
varSortDirection
),
"Approved by MGT",
SortByColumns(
Filter(
'Projects',
StartsWith(
Title,
SearchBox.Text
) && 'Approval Status' = "Approved by MGT"
),
varSortColumn,
varSortDirection
)

 

PG_WorXz10
Resident Rockstar
Resident Rockstar

Hi @BauwensER3,

Could you please  let me know the Dropdown items data also ?

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

BauwensER3
Frequent Visitor

The items for the dropdown are basically the colViews

PG_WorXz10
Resident Rockstar
Resident Rockstar

Hi @BauwensER3 ,

 

The issue seems due colViews.ViewName is a collection and dropdown.selected.ViewName is text 

 

PriyankaMadan10_0-1627913661962.png

So instead of using collection value in the Filter try using the Project column value. Let me know if further help required. 

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.  

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

BauwensER3
Frequent Visitor

Sorry but are you implying that I need to make the change on the OnSelect Event? :

 

GeneratePDFProject.Run(User().Email,
JSON(
Filter(
'Projects',
colViews.ViewName = Dropdown.Selected.ViewName

),
IgnoreUnsupportedTypes & JSONFormat.IgnoreBinaryData
)
);

 

 

Hi @BauwensER3,

 

Instead of directly using colViews.ViewName in Filter is it possible to use any columns from Project datasource ? 

 

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

ok, the only column that I could use from the project data source which is a SharePoint list is named

'Approval Status' but I am not really interested in reports on the Approval Status. I want to be able to achieve that when users select "My projects" that it produces a report with only the projects that they submitted for approval, and when they select "All Projects" a report should be produced listing all of the projects submitted.

 

This is what I have in Items on my datatable:

 

Switch(
Dropdown.Selected.ViewName,
"My Projects",
SortByColumns(
Filter(
'Projects',
StartsWith(
Title,
SearchBox.Text
) && 'Created By'.Email = User().Email || StartsWith(
'Brief description of the work',
SearchBox.Text
) && 'Created By'.Email = User().Email || StartsWith(
'Location of Work',
SearchBox.Text
) && 'Created By'.Email = User().Email
),
varSortColumn,
varSortDirection
),
"All Projects",
SortByColumns(
Search(
'Projects',
SearchBox.Text,
"Title",
"Briefdescriptionofthework",
"LocationofWork"
),
varSortColumn,
varSortDirection
),
"Pending Approval",
SortByColumns(
Filter(
'Projects',
StartsWith(
Title,
SearchBox.Text

) && 'Approval Status' = "Pending Approval"
),
varSortColumn,
varSortDirection
)

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,497)