Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Expression Refers to Multiple Columns Error when FILTER put inside Switch

I have a table containing different dates (dateARInitiateComplete,  dateARScreenComplete, dateARCloseComplete).  These values need to be sent to the filter and then returned in the calculated table as Complete.  The code works fine so long as I'm only using one condition (First Example).  When I add Switch (Example 2), I get  the error message "The expression refers to multiple columns.  Multiple columns cannot be converted to a scalar value".   I can't figure out how to switch out one column name for another to be able to filter the specific column selected.

 
Example 1 - working
TesttblVarvDateField =
VAR vBeg = EDATE ( TODAY(), -1 )
VAR vEnd = EOMONTH ( TODAY(), -1 )
VAR vSelected = SELECTEDVALUE(lkupWorkFlowSteps[agDescription])
var vFilter =
      FILTER
        (
           'tblCR',
           'tblCR'[DateARScreenComplete] >= vBeg &&
           'tblCR'[DateARScreenComplete] <= vEnd
        )
 
RETURN
 ADDCOLUMNS
(
   SUMMARIZE
    (
     vFilter,
           'tblCR'[FSA],
            'tblCR'[iCASNumber],
            'tblCR'[DateARScreenComplete]
    ),
        "Complete", 'tblCR'[DateARScreenComplete]
)

 



 

Example 2 - not working
TesttblVarvDateField =
VAR vBeg = EDATE ( TODAY(), -1 )
VAR vEnd = EOMONTH ( TODAY(), -1 )
VAR vSelected = SELECTEDVALUE(lkupWorkFlowSteps[agDescription])
var vFilter =
SWITCH
(
   TRUE(),
   vSelected = "AR INITIATE",
      FILTER
        (
           'tblCR',
           'tblCR'[DateARScreenComplete] >= vBeg &&
           'tblCR'[DateARScreenComplete] <= vEnd
        )
  )
RETURN
 ADDCOLUMNS
(
   SUMMARIZE
    (
     vFilter,
           'tblCR'[FSA],
            'tblCR'[iCASNumber],
            'tblCR'[DateARScreenComplete]
    ),
        "Complete", 'tblCR'[DateARScreenComplete]
)

1 Reply