Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
cocuzzan
Partner - Contributor III
Partner - Contributor III

FirstSortedValue with dimensions from aggr

Hi I can't get the FirstSortedValue statement to work to retrieve the first value that comes from an aggr. In summary: I have two variables and the demos show in the table. After that I need to retrieve the description (class) of the greater value. then I write the variable (Test) with the FirstSortedValue statement. Unfortunately it doesn't work. I think because the FirstSortedValue wants dimensions and not an instruction that contains an aggr inside. Advice ??

 

 

//Divisione in classi
SET O11010203_O11010203_CMYTD_VLV_Classi =
aggr(
if(alt($(O11010203_CMYTD_VLV_INVENTORY_TURNOVER),0)>alt($(O11010203_CMYTD_VLV_INVENTORY_MOVING_Y),0), 'veloce',
if(alt($(O11010203_CMYTD_VLV_INVENTORY_TURNOVER),0)>alt($(O11010203_CMYTD_VLV_INVENTORY_MOVING_X),0) and alt($(O11010203_CMYTD_VLV_INVENTORY_TURNOVER),0)<=alt($(O11010203_CMYTD_VLV_INVENTORY_MOVING_Y),0), 'attiva',
if(alt($(O11010203_CMYTD_VLV_INVENTORY_TURNOVER),0)>0 and alt($(O11010203_CMYTD_VLV_INVENTORY_TURNOVER),0)<=alt($(O11010203_CMYTD_VLV_INVENTORY_MOVING_X),0), 'lenta',
if(alt($(O11010203_CMYTD_VLV_INVENTORY_TURNOVER),0)=0, 'ferma'))))
, O11010203_ID_ITEM)
;
SET O11010203_O11010203_CMYTD_Classi_RPL = = Replace(O11010203_O11010203_CMYTD_VLV_Classi, '§', '$');


// CLOSING_INVENTORY
SET O11010203_CMYTD_VLV_CLOSING_INVENTORY = sum({<[ThFiltri.YEAR]=,[ThFiltri.MONTH] =, O11010203_DATE_ACCRUAL = {">=§(=§(O11010203_vMinDate2))<=§(=§(O11010203_vMaxDate))"}>} O11010203_VALORE_SALDO);
SET O11010203_CMYTD_FRM_CLOSING_INVENTORY = num( $(O11010203_CMYTD_VLV_CLOSING_INVENTORY)/1000 ,$(FMT_KEuro));
SET O11010203_CMYTD_CLOSING_INVENTORY_RPL = = Replace(O11010203_CMYTD_FRM_CLOSING_INVENTORY, '§', '$');


SET O11010203_test =
FirstSortedValue( {<[ThFiltri.YEAR]=,[ThFiltri.MONTH] =>} distinct $(O11010203_O11010203_CMYTD_VLV_Classi) , -AGGR ( nodistinct $(O11010203_CMYTD_VLV_CLOSING_INVENTORY),$(O11010203_O11010203_CMYTD_VLV_Classi)),1 );
SET O11010203_test_RPL = = Replace(O11010203_test, '§', '$');

0 Replies