Hi
See attached spreadsheet for an illustration. But note, the values in ProgramDetails are Text in the real database
For quick reference, a slimmed down version of the data looks like this:
ProgramList
PROGRAM.......START_DATE
X-ABC123....... 12/04/2012
None in force.... 31/05/2018
Y-34-FG-343..... 24/02/2019
ProgramDetails
PROGRAM_CODE.....YEAR.......PERCENT
X-ABC123..................... 1.................. 20
X-ABC123..................... 2..................100
Y-34-FG-343.................. 1..................30
Y-34-FG-343...................2..................60
Y-34-FG-343...................3..................100
I want a query that returns
PROGRAM........START_DATE.......DURATION
X-ABC123..........12/04/2012....................2
None in force.......31/05/2018.................... this should be blank/NULL
Y-34-FG-343.......24/02/2019....................3
where DURATION is now a number
I've written a query in Design View with a Totals row.
I've got a "Include all records from ProgramList" joint
Then I've written an expression that says
Duration: IIF([PROGRAM] = "None in force", NULL, Max(Val[Year])))
I'm getting the message
Data type mismatch in criteria expression
I don't understand why that is?
I'm not telling it to perform a Max function if Program was "None in force", just simply return NULL.
Can someone please explain why it's not that simple?
Thanks
See attached spreadsheet for an illustration. But note, the values in ProgramDetails are Text in the real database
For quick reference, a slimmed down version of the data looks like this:
ProgramList
PROGRAM.......START_DATE
X-ABC123....... 12/04/2012
None in force.... 31/05/2018
Y-34-FG-343..... 24/02/2019
ProgramDetails
PROGRAM_CODE.....YEAR.......PERCENT
X-ABC123..................... 1.................. 20
X-ABC123..................... 2..................100
Y-34-FG-343.................. 1..................30
Y-34-FG-343...................2..................60
Y-34-FG-343...................3..................100
I want a query that returns
PROGRAM........START_DATE.......DURATION
X-ABC123..........12/04/2012....................2
None in force.......31/05/2018.................... this should be blank/NULL
Y-34-FG-343.......24/02/2019....................3
where DURATION is now a number
I've written a query in Design View with a Totals row.
I've got a "Include all records from ProgramList" joint
Then I've written an expression that says
Duration: IIF([PROGRAM] = "None in force", NULL, Max(Val[Year])))
I'm getting the message
Data type mismatch in criteria expression
I don't understand why that is?
I'm not telling it to perform a Max function if Program was "None in force", just simply return NULL.
Can someone please explain why it's not that simple?
Thanks
Attachments
Last edited: