cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
warrencowan
Helper I
Helper I

DAX Calculate function, throws error when using calculated measure as filter

 
Hi all, I'm floundering with a calculate function, to sum ad spend, where the ROAS is less than X.
 
In this case, ad spend is a static column of data for each row,
and ROAS is a calculated measure, created from revenue/spend using the following formula. 
  • ROAS = if(iserror(sum('GA-Adwords Table'[Revenue (EUR)])/sum('GA-Adwords Table'[Ad spend (EUR)]))=true,0,sum('GA-Adwords Table'[Revenue (EUR)])/sum('GA-Adwords Table'[Ad spend (EUR)]))
However my calculate function....
  • NCS = CALCULATE(sum('GA-Adwords Table'[Ad Spend (EUR)]), [ROAS]<1)
throws the below error message.
  • A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.
Can anyone point to what I'm doing wrong.
 
Any help, critque or abuse for being daft, gratetfully appreciated.
1 ACCEPTED SOLUTION
v-sihou-msft
Microsoft
Microsoft

@warrencowan

 

As the error message said, in CALCULATE() function, the second parameter can be a True/False expression. You need to put a filted table context. So your formula should be like:

 

NCS =
CALCULATE (
    SUM ( 'GA-Adwords Table'[Ad Spend (EUR)] ),
    FILTER ( 'GA-Adwords Table', [ROAS] < 1 )
)

Regards,

 

View solution in original post

3 REPLIES 3
sibanez
Regular Visitor

I have this error:

 

"RUBRO_C16",IF(VALOR_SALUD_COL_IND[COD RAMO CONT FINAL] IN {"045","034"},CALCULATE(SUM(VALOR_SALUD_COL_IND[VALOR_CALCULADO]),
FILTER(VALOR_SALUD_COL_IND,VALOR_SALUD_COL_IND[COD RUBRO FINAL] = "C16" )),
CALCULATE((SUM(VALOR_SALUD_COL_IND[VALOR_CALCULADO])),
FILTER(VALOR_SALUD_COL_IND,VALOR_SALUD_COL_IND[COD RUBRO FINAL] = "C16" ))),

 

The True/False expression does not specify a column. Each True/False expressions used as a table filter expression must refer to exactly one column.

v-sihou-msft
Microsoft
Microsoft

@warrencowan

 

As the error message said, in CALCULATE() function, the second parameter can be a True/False expression. You need to put a filted table context. So your formula should be like:

 

NCS =
CALCULATE (
    SUM ( 'GA-Adwords Table'[Ad Spend (EUR)] ),
    FILTER ( 'GA-Adwords Table', [ROAS] < 1 )
)

Regards,

 

Anonymous
Not applicable

This solved my problem! thank you kindly!

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors