Hi
I have a Datatable that pulls back all the Delivery notes from a Part number. It uses the below formula:
With({aFilter: Filter('Tbl Delivery Dev2','ORDER REF'=POTableDescrip_1.Selected.'ORDER REF')},
Filter(aFilter,
If(TogDesPO2.Value,'ORDER REF'=POTableDescrip_1.Selected.'ORDER REF',true),
If(TogDesDelivery2.Value,STATUS="Delivered",true)
)
)
I have a toggle(TogDesPO2.Value) that looks at another datatable, which contains Purchase Order numbers for the same part number.
When the toggle is off it should bring back all the delivery notes for that part number, which it doesn't. When the toggle is on, it should only show the delivery notes for the selected Purchase Order number, which it does.
Any help would be appreciated.
Hi @Skybluekid,
As I understand it now the initial With filter is necessary. However, the initial filter also filters on the selected reference from POTableDescrip_1 - to my understanding this should be the Part Number filter. Below you can find a sketch of the possible architecture:
With(
{
//Filter by part number
aFilter: Filter('Tbl Delivery Dev2',PartNumberColumn = PartNumberValue)
},
Filter(
aFilter,
//Or toggle is false, or filter by order ref
!TogDesPO2.Value || 'ORDER REF' = POTableDescrip_1.Selected.'ORDER REF',
!TogDesDelivery2.Value || STATUS = "Delivered"
)
)
Please adjust PartNumberColumn to the correct column name and PartNumberValue to the current part number value.
I hope this helps!
Thanks @LaurensM
I think I made a slight error when describing. What I should have said is that if in the PO Table it has returned two PO for a part number, the unfiltered Delivery note table should return all delivery notes for those two PO's only, not all delivery notes in the list. Then if the TogDesPO2 is switched to true then only the selected value delivery notes are displayed.
You prefilter the table by order reference and then run the same order reference filter condition on the filtered dataset only if a toggle is set to true. I don't think the With() function is necessary here, could you try the following adjustment:
Filter(
'Tbl Delivery Dev2',
//Or toggle is false, or filter by order ref
!TogDesPO2.Value || 'ORDER REF'=POTableDescrip_1.Selected.'ORDER REF',
!TogDesDelivery2.Value || STATUS="Delivered"
)
The code above also avoids the If statement that could cause issues (delegation warnings & true output that does not return any records).
If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.
Thanks!