Forum Discussion
SQLMonger
Advocate II
3 years agoMany-to-Many Currency Conversion - DAX Error returning final result for Backlog measure
I’ve run into a DAX challenge that has me stumped. This lengthy post describes the business problem to be resolved and the steps I took to come up with and debug the solution. Necessary background in...
SQLMonger
Advocate II
3 years agoMahesh0016 Thank you for the response.
I tried your suggestion:
MEASURE 'Sales Order'[Backlog Amt Aggregated] =
VAR _LastDateInRange =
CALCULATE(
MAX( Calendar[Date] ),
FILTER( ALL( 'Calendar' ), 'Calendar'[Date] = MAX( 'Calendar'[Date] ))
)
VAR AggregatedSalesInCurrency =
ADDCOLUMNS (
SUMMARIZE ('Sales Order',
'Source Currency'[Source Currency Code]
),
"@Backlog", [Loc Backlog] * LOOKUPVALUE(
'Currency Rate'[Rate] ,
'Currency Rate'[CalendarDate], _LastDateInRange,
'Currency Rate'[ToCurrencyCode], SELECTEDVALUE( 'Target Currency'[Target Currency] ),
'Currency Rate'[FromCurrencyCode], 'Source Currency'[Source Currency Code]
)
)
RETURN AggregatedSalesInCurrency
MEASURE 'Sales Order'[Backlog Amt] =
IF (
NOT ( HASONEVALUE( 'Target Currency'[Target Currency Code] ) ),
ERROR( "Select a single Target Currency Code" ),
VAR AggregatedSalesInCurrency = [Backlog Amt Aggregated]
VAR Result = SUMX( AggregatedSalesInCurrency, [@Backlog])
RETURN Result
)Unfortunately it did not work. I split the measure as you suggested, and both measures throw errors in Tabular Editor:
[Backlog Amt Aggregated] - "MeasureExpression: The measure refers to multiple columns. Multiple columns cannot be converted to a Scalar value."
Which results in [Backlog Amt] throwing an error as well. Just for grins, I deployed and tested each measure using Power BI Desktop, but it does not work there either.
I've tried refactoring the calculation into multiple steps within the measure as well, all with the same result. The inability to convert the table variable to a scalar result.