Forum Discussion
multiple columns cannot be converted to a scalar value for power bi on Direct Query
- 7 years ago
Hey,
I have to admit that I do not understand what the formula is doing exactly, but by analyzing the parenthesis it seems that the false part of the first IF is a SUMMARIZE ...
Terra Accuracy = VAR __History = SUM('V_FORECASTACCURACY'[DeliveryQty in SU]) VAR __Terraforecast = SUM('V_FORECASTACCURACY'[TRR-Forecast Qty]) RETURN if( HASONEFILTER(US_MATERIAL[GTIN]) ,iF( NOT ISBLANK(__history) ,if(__History<>0 ,if((1-DIVIDE(abs( __history-__Terraforecast), __History))>0 ,(1-DIVIDE(abs( __history-__Terraforecast), __History)) ))) ,SUMMARIZE( V_FORECASTACCURACY ,US_MATERIAL[Material Text] ,"acc", 1-DIVIDE(abs( __history-__Terraforecast), __History)*__History/sum(V_FORECASTACCURACY[DeliveryQty in SU]) /CALCULATE(SUM('V_FORECASTACCURACY'[DeliveryQty in SU]),ALLEXCEPT(US_MATERIAL,US_MATERIAL[Product Line]))) )The SUMMARIZE returns two columns [Material Text] and [acc]. A table with more than one column and more than one row cannot be converted implicitly into a scalar value.
Maybe you need to iterate over the table returned by a SUMX(SUMMARIZE(...), [acc]), but this is just guesswork.
Hopefully, this gets you started.
Regards,
Tom
Hey,
I have to admit that I do not understand what the formula is doing exactly, but by analyzing the parenthesis it seems that the false part of the first IF is a SUMMARIZE ...
Terra Accuracy =
VAR __History = SUM('V_FORECASTACCURACY'[DeliveryQty in SU])
VAR __Terraforecast = SUM('V_FORECASTACCURACY'[TRR-Forecast Qty])
RETURN
if(
HASONEFILTER(US_MATERIAL[GTIN])
,iF( NOT ISBLANK(__history)
,if(__History<>0
,if((1-DIVIDE(abs( __history-__Terraforecast), __History))>0
,(1-DIVIDE(abs( __history-__Terraforecast), __History))
)))
,SUMMARIZE(
V_FORECASTACCURACY
,US_MATERIAL[Material Text]
,"acc",
1-DIVIDE(abs( __history-__Terraforecast), __History)*__History/sum(V_FORECASTACCURACY[DeliveryQty in SU])
/CALCULATE(SUM('V_FORECASTACCURACY'[DeliveryQty in SU]),ALLEXCEPT(US_MATERIAL,US_MATERIAL[Product Line])))
)
The SUMMARIZE returns two columns [Material Text] and [acc]. A table with more than one column and more than one row cannot be converted implicitly into a scalar value.
Maybe you need to iterate over the table returned by a SUMX(SUMMARIZE(...), [acc]), but this is just guesswork.
Hopefully, this gets you started.
Regards,
Tom
- SinduN7 years ago
Helper I
Thank you Tom. I had to sumx for the summarize section. Issue was that the summarize was giving a table of the measure"acc". using Sumx of the measure "acc" fixed the issue. Instead if using one big formula - i broke it into 2 measures and used teh dame concept and it worked.
test =
VAR __History = SUM('V_FORECASTACCURACY'[DeliveryQty in SU])
VAR __Terraforecast = SUM('V_FORECASTACCURACY'[TRR-Forecast Qty])
RETURN
if(
HASONEFILTER(US_MATERIAL[GTIN])
,iF( NOT ISBLANK(__history)
,if(__History<>0
,if((1-DIVIDE(abs( __history-__Terraforecast), __History))>0
,(1-DIVIDE(abs( __history-__Terraforecast), __History))
)))
,sumx(SUMMARIZE(
V_FORECASTACCURACY
,US_MATERIAL[Material Text]
,"Acc",
(1-DIVIDE(abs( __history-__Terraforecast), __History)*__History/sum(V_FORECASTACCURACY[DeliveryQty in SU])
/CALCULATE(SUM('V_FORECASTACCURACY'[DeliveryQty in SU]),ALLEXCEPT(US_MATERIAL,US_MATERIAL[Product Line])))),[Acc]))