Search code examples
olap-cubessas-2008ssas-2012ssas-tabular

Filter based on column which is not in summarize "DAX"


Today I would like to generate result based on following "DAX" query but it return following error.

evaluate ( filter ( summarize ( 'Date', 'Date'[Numeric Month] ), AND ('Date'[Numeric Month] >=(YEAR(TODAY())-1)* 100 + 1,'Date'[NumericDate] <=TODAY()) ) )

Error:

Query (11, 60) A single value for column 'Numeric Date' in table 'Date' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

I have tried various expect with

ADDCOLUMNS,SUMMARIZE

But nothing work for this. I just want ('Date'[Numeric Month]) in output.


Solution

  • I am not sure what you try to achieve here. Just want distinct Numeric Months as an output? If yes do this:

    EVAULATE(
    VALUES('Date'[Numeric Month])
    )
    

    Otherwise you should move your Date'[NumericDate] <=TODAY() to an iterator, so pass a FILTER as a first argument to summarize

    evaluate
    (
    filter
       (
       summarize
       (
         filter('Date',
         'Date'[NumericDate] <=TODAY()
         )
         'Date'[Numeric Month]
       ),
        'Date'[Numeric Month] >=(YEAR(TODAY())-1)* 100 + 1
       )
    )