Assumptions:
-
You’re trying to populate columns in the Reports table.
-
a virtual column in the “Tickets” table which combines the project-date-kilometer-lane&lift columns into a group identifier and the primary key in the “Reports” table is the same are both named Group ID.
For the Valid_If formula for the Project column of the Reports table:
=SORT(
SELECT(
Ticket[Project],
OR(
([Group ID] = [_THISROW].[Group ID]),
NOT(IN([Group ID], Reports[Group ID]))
),
TRUE
) )
-
SORT(…) sorts the generated list of Project column values. This step is entirely optional.
-
SELECT(Ticket[Project], …, TRUE) gathers distinct (per TRUE) values from the Project column of the Tickets table from rows that match the given criteria (below).
-
OR(…, …) requires that at least one of the given criteria (below) is TRUE.
-
([Group ID] = [_THISROW].[Group ID]) matches the report for the Tickets row. This will only match once the Group ID for the report is assembled completely, and is needed to ensure the validation rule validates the completed rule. If this exception isn’t present, the step below would cause the validation to fail.
-
NOT(IN([Group ID], Reports[Group ID])) matches only those rows in the Tickets table in which the Group ID column value does not occur in the Group ID column of the Reports table. This excludes Tickets rows with configured reports from consideration.
The above effectively gets a list of projects from tickets that do not currently have configured reports.
For the Date column of the Reports table:
=IFS(
ISNOTBLANK([Project]),
SORT(
SELECT(
Ticket[Date],
OR(
([Group ID] = [_THISROW].[Group ID]),
AND(
([Project] = [_THISROW].[Project]),
NOT(IN([Group ID], Reports[Group ID]))
)
),
TRUE
)
) )
-
IFS(ISNOTBLANK([Project]), …) will only produce a result (a list of Date values from the Tickets table) if the current Reports row’s Project column is not blank. This effectively requires the user select a project before being given a list of dates.
-
SORT(…) sorts the generated list of Project column values (below). This step is entirely optional.
-
SELECT(Ticket[Date], …, TRUE) gathers distinct (per TRUE) values from the Date column of the Tickets table from rows that match the given criteria (below).
-
OR(…, …) requires that at least one of the given criteria (below) is TRUE.
-
([Group ID] = [_THISROW].[Group ID]) matches the report for the Tickets row. This will only match once the Group ID for the report is assembled completely, and is needed to ensure the validation rule validates the completed rule. If this exception isn’t present, the validation would fail.
-
AND(…, …) requires that all of the given criteria (below) must be TRUE.
7 ([Project] = [_THISROW].[Project]) matches only rows in which the Project column value matches this report’s Project column value.
- NOT(IN([Group ID], Reports[Group ID])) matches only those rows in the Tickets table in which the Group ID column value does not occur in the Group ID column of the Reports table.
The above effectively gets a list of dates from tickets for this report’s project that do not currently have configured reports.
Similarly, for the Kilometers column of the Reports table:
=IFS(
ISNOTBLANK([Date]),
SORT(
SELECT(
Ticket[Kilometer],
OR(
([Group ID] = [_THISROW].[Group ID]),
AND(
([Date] = [_THISROW].[Date]),
([Project] = [_THISROW].[Project]),
NOT(IN([Group ID], Reports[Group ID])
)
),
TRUE
)
) )
And the Lane & Lift column:
=IFS(
ISNOTBLANK([Kilometer]),
SORT(
SELECT(
Ticket[Lane & Lift],
OR(
([Group ID] = [_THISROW].[Group ID]),
AND(
([Kilometer] = [_THISROW].[Kilometer]),
([Date] = [_THISROW].[Date]),
([Project] = [_THISROW].[Project]),
NOT(IN([Group ID], Reports[Group ID])
)
),
TRUE
)
) )