cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper III
Helper III

Filter Gallery From Multiple Sources

OK. I have been looking for a resolution but not able to find.
Hoping someone could provide some direction.

 

On my screen, I have 2 dropdowns and a gallery.
The Gallery displays records (TaskName) which are filtered by the 2 dropdowns, (Location and Frequency) from the CAMT table.
CAMT table has TaskID, TaskName,Location and Frequency columns.

When you click the right arrow, it Patches the Location, Frequency, TaskID and Datetime to the CAMR table. (note, different table)

What I would like to do is:
Once the record for this task has been patched on today`s date to the CAMR table, remove it from the gallery so it can`t be done twice in one day.

 

In essence, removing tasks from the list which have been done today.

If anyone is able to provide some suggestions it would be greatly appreciated.

Really having trouble figuring out how to filter with these 2 tables.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Yes you can use the Value() or Text() function, basically like this :

Value("1") = 1

Text(1) = "1"

 

I suggest you to convert your varchar column, so let say that it is the CAMR_Task column tha tis varchar, you should have something like this :

Text(LookUp('[dbo].[WHS_CAMRecords]',Value(CAMR_Task)= ...

 

Théo 

View solution in original post

18 REPLIES 18
Memorable Member
Memorable Member

Hi @kevinsray,

 

So your condition is basically CAMR table record must have a date different than today ? right ? 

Can you try :

Filter(CAMT,Text(LookUp(CAMR,CAMT[@TaskID]=CAMR[@TaskID],Datetime),DateTimeFormat.ShortDate)<>Text(Today(),DateTimeFormat.ShortDate))

The lookup part is used to get the datetime value for a taskID from the CAMT table.

Then the Text() function is used to convert your datetime column into a text representing the date only, and compare this to today's date with the same formatting.

 

Théo

Not really.
The gallery shows the records from the CAMT table, and I want to hide any of the records in this gallery, which have today`s datetime stamp in the CAMR table for the task.

CAMT Tablehas ID and TASKNAME columns.
CAMR table has ID and DATETIME columns.

 

So, when user clicks button on screen, patches to CAMR with ID and datetime.
Once this is done, I want to remove the TASKNAME from the gallery which comes from CAMT.

 

Hoping this clears it up a little.

Hi @kevinsray

So, if you want to hide CAMT items that have todays date into the CAMR table, that means you want to show CAMT items that have a CAMR record with a date different than today, right ?

 

I think my formula should work, you just need to Refresh(datasource) when you set the item date to make sure PowerApps is aware of the change.

 

Théo

Theo,

Thank you very much for your assistance.

Very close.

I want to show the CAMT items which don`t have today`s date in the CAMR table.

I put your code in, and updates sources, but still not working. This is code I have now:
Filter('[dbo].[WHS_CAMTasks]',Text(LookUp('[dbo].[WHS_CAMRecords]',CAMTask_ID[@TaskID]=CAMR_Task[@TaskID],Datetime),DateTimeFormat.ShortDate)<>Text(Today(),DateTimeFormat.ShortDate))

 

I have attached screenshots of the 2 tables and the input screen so you understand what they look like.

Basically, they will click on the right arrow to say they have done the task.
This patches the info to the CAMR table.

You may notice that the input screen has 2 dropdowns. Also need to filter to those, so not sure how to incorporate that.

Thank you VERY much for your assistance. It is greatly appreciated.

I had used the disambiguation notation TableName[@ColumnName] because I thought the task ID column had the same name in the 2 tables. I can see this is not the case, so you can write the formula this way, including the 2 dropdown filters :

 

Filter('[dbo].[WHS_CAMTasks]',
Text(LookUp('[dbo].[WHS_CAMRecords]',CAMR_Task=CAMTask_ID,CAMR_Date),DateTimeFormat.ShortDate)<>Text(Today(),DateTimeFormat.ShortDate)
&& CAMT_Location = LocationDropDownList.Selected.Value
&& CAMT_Frequency = FrequencyDropDownList.Selected.Value)

You have to replace LocationDropDownList and FrequencyDropDownList with the dropdownlist control names you have in your app.

But first of all I suggest you to validate the Date filter, so remove the filters about location and frequency.

Once you know the date filter is ok then you can add the 2 others filter. I'll be easier if something wrong to identify what is it doing like this, step by step.

 

Théo

Theo,

Thank you again.

Nice to know that I can use the &&.

I removed the dropdown filters as suggested and it showed a lot of records.

So, I changed <> to = to get records with today`s date, but nothing shows.

In corner of Gallery is yellow triangle and it says 2 different data types. Text and Number.

When I click on the filter in Items, it has blue line, delegation warning.

Really appreciate your help.

 

This thing is you don't want to see item that have a date = to today, you want to hide them, so you want to display items that have a date different (<>) than today.

 

Can you check if the "CAMR_Task" column in CAMR table and the "CAMTask_ID" column in CAMT table have the same type (seems that one of them is a Text and the other a Number).

 

The delegation warning is probably about the Today() function, you should try to fix it by setting a variable OnStart of your app : Set(varToday,Today()) and then in your filter use varToday instead of Today().

 

Théo

 

Théo

 

 

Oh sorry, I missread your post.

 

You telling me that the comparison of date is not working because changing the condition to = should show all record that have today's date, right ?

We'll need to check the condition then. Can you add a label somewhere (just to debug, you'll remove it after) and set the Text property to :

Text(LookUp('[dbo].[WHS_CAMRecords]',CAMR_Task=First('[dbo].[WHS_CAMTasks]').CAMTask_ID,CAMR_Date),DateTimeFormat.ShortDate)

and another label with the Text property set to :

Text(Today(),DateTimeFormat.ShortDate)

I just want to compare the formatting, because we need to compare things formatted the same way.

 

Théo

 

Theo,

OK. I made it <> and there is a lot of data there.

I checked the DB again and yep. One is an int and the other varchar...

Is there a way to fix this in powerapps rather than on DB side?

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Top Solution Authors
Top Kudoed Authors
Users online (75,659)