Search an Enum Help?

Hi all,
Iโ€™ve come slightly stuck on an expression for an app iโ€™m building and canโ€™t get my head around it.

I have 2 tables โ€œIn Stockโ€ and โ€œExpensesโ€
โ€œIn Stockโ€ table has a VC that sums the expenses related to each individual stock item.

In the โ€œExpensesโ€ table I have a column called โ€œVAT Applicableโ€ the data type is Enum with options of โ€œYesโ€ and โ€œNoโ€

Essentially what iโ€™m trying to achieve is:
SELECT Expenses[Price] WHERE [Car Id] = [_THISROW].[ID] AND Expenses[VAT Applicable] = Yes

The expression formula iโ€™ve currently got is:

SUM(
  SELECT
(
Expenses[Price],
AND(
    ([Car Id] = [_THISROW].[ID]), 
    (IN( Yes , Expenses[VAT Applicable] ) = Yes)
     )
)
  )

This expression just returns all the expenses related to that ID regardless of [VAT Applicable] being โ€œYesโ€ or โ€œNoโ€

Thanks in advance,
Look forward to your responses,

Dave.

0 3 113
3 REPLIES 3

Aurelien
Google Developer Expert
Google Developer Expert

Hi @David_Taylor,

Can you try:

SUM(
  SELECT(Expenses[Price],
     AND(
       [Car Id] = [_THISROW].[ID], 
       [VAT Applicable]
    )
  )
)

I assume here that [VAT Applicable] is of type Yes/No.
If not, please try:

SUM(
  SELECT(Expenses[Price],
     AND(
       [Car Id] = [_THISROW].[ID], 
       [VAT Applicable]="Yes"
    )
  )
)

Let us know if that works

Cheers

Tried the second option:

SUM(
  SELECT(Expenses[Price],
     AND(
       [Car Id] = [_THISROW].[ID], 
       [VAT Applicable]="Yes"
    )
  )
)

All working thank you very much for your help!

Think half my issue in my experimenting was having the table name in front of the column when I didnโ€™t need it. โ€œExpenses[VAT Applicable]โ€

Thanks this helped alot!

Probably, SELECT expressions may be tricky sometimes.

You are welcome !

Top Labels in this Space