Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hello guys i have the next code, but i dont feel comfortable with to many ifs, somebody can give me an advice to short this code?
if(match(ConceptoInline,'Ventas Netas'),
sum({<Concepto={'VENTAS'},MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000),
if(match(ConceptoInline,'Costo de Ventas'),
sum({<Concepto={'COSTO DE VENTAS'}, MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000),
if(match(ConceptoInline,'Gastos de Administración, Comerciales y Generales'),
sum({<Concepto={'GASTOS DE ADMINISTRACION'}, MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000),
if(match(ConceptoInline,'Depreciación y Amortización'),
sum({<Concepto={'DEPRECIACION ACUMULADA'}, MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000),
if(match(ConceptoInline,'Costo Financiero (Neto)'),
sum({<Concepto={'GASTOS FINANCIEROS'}, MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000),
if(match(ConceptoInline,'Fluctuación Cambiaria (Neta)'),
sum({<Concepto={'OTROS INGRESOS (GASTOS)'}, MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000),
if(match(ConceptoInline,'Participación en Subs. y Asoc.'),
sum({<Concepto={'PARTICIPACION RESULTADOS DE SUBSIDIARIAS Y ASOC.'}, MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000),
if(match(ConceptoInline,'Impuestos y PTU'),
sum({<Concepto={'IMPUESTOS Y PTU'}, MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000)
,
if(match(ConceptoInline,'Utilidad Bruta'),
sum({<Concepto={'VENTAS','COSTO DE VENTAS'},MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000)
,
if(match(ConceptoInline,'EBITDA'),
sum({<Concepto={'VENTAS','COSTO DE VENTAS','GASTOS DE ADMINISTRACION'},MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000)
,
if(match(ConceptoInline,'Utilidad (Pérdida) antes de Impuestos y PTU'),
sum({<Concepto={'VENTAS','COSTO DE VENTAS','DEPRECIACION ACUMULADA','GASTOS FINANCIEROS','OTROS INGRESOS (GASTOS)','GASTOS DE ADMINISTRACION','PARTICIPACION RESULTADOS DE SUBSIDIARIAS Y ASOC.'},
MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000)
,
if(match(ConceptoInline,'Utilidad (Pérdida) Neta'),
sum({<Concepto={'VENTAS','COSTO DE VENTAS','DEPRECIACION ACUMULADA','GASTOS FINANCIEROS','OTROS INGRESOS (GASTOS)','IMPUESTOS Y PTU','GASTOS DE ADMINISTRACION','PARTICIPACION RESULTADOS DE SUBSIDIARIAS Y ASOC.'},
MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000)
this really depends on what you want to do. if you model your data correctly, you can associate your 2 fields ConceptoInline and Concepto
and assuming that you will use this expression in a table, if you have ConceptoInline as a dimension, your expression will be
sum({<MONEDA,[Fecha.Doc]={">=$(=MakeDate(AñoC, 1, 1)) <=$(=MakeDate(AñoC, MesC, DiaC))"}>} ImporteDMBTR/1000)
you will not need the phrase Concepto={'...'} because the data model will do it for you
you may want to share your data and what you want to achieve
conceptoiline its a table inline that contain concepts that dont exist in the original model from concepto(this info come from a SAP Connector)
This is what i achieve the background in blue are concepts that i have to create in the table inline like this
ERBancos:
LOAD * INLINE [
ID,ConceptoInline, ConceptoMatch
1,'Ventas Netas','VENTAS'
2,'Costo de Ventas','COSTO DE VENTAS'
3,'Utilidad Bruta',Null()
4,'Gastos de Administración, Comerciales y Generales','GASTOS DE ADMINISTRACION'
5,'EBITDA',Null()
6,'Depreciación y Amortización','DEPRECIACION ACUMULADA'
7,'Costo Financiero (Neto)','GASTOS FINANCIEROS'
8,'Fluctuación Cambiaria (Neta)','OTROS INGRESOS (GASTOS)'
9,'Participación en Subs. y Asoc.','PARTICIPACION RESULTADOS DE SUBSIDIARIAS Y ASOC.'
10,'Utilidad (Pérdida) antes de Impuestos y PTU',Null()
11,'Impuestos y PTU','IMPUESTOS Y PTU'
12,'Utilidad (Pérdida) Neta',Null()
];
this is where the concepts came
Set vConcepto =
if(num#([G/L Account_HKONT]) >= '4000000000' and num#([G/L Account_HKONT]) <= '4999999999' AND ApplyMap('MapeoCONCEPTOSFBL3N', Num#([G/L Account_HKONT]))<>'PARTICIPACION RESULTADOS DE SUBSIDIARIAS Y ASOC.','VENTAS',
if(num#([G/L Account_HKONT]) >= '5400000000' and num#([G/L Account_HKONT]) <= '5499999999' AND ApplyMap('MapeoCONCEPTOSFBL3N', Num#([G/L Account_HKONT]))<>'DEPRECIACION ACUMULADA', 'COSTO DE VENTAS' ,
if(num#([G/L Account_HKONT]) >= '5500000000' and num#([G/L Account_HKONT]) <= '5599999999' AND ApplyMap('MapeoCONCEPTOSFBL3N', Num#([G/L Account_HKONT]))<>'IMPUESTOS Y PTU', 'GASTOS DE ADMINISTRACION' ,
if(num#([G/L Account_HKONT]) >= '6000000000' and num#([G/L Account_HKONT]) <= '7999999999' AND ApplyMap('MapeoCONCEPTOSFBL3N', Num#([G/L Account_HKONT]))<>'OTROS INGRESOS (GASTOS)', 'GASTOS FINANCIEROS',
Coalesce(
ApplyMap('MapeoCONCEPTOSCxC', num#([G/L Account_HKONT]),null()),
ApplyMap('MapeoCONCEPTOSCxP',num#([G/L Account_HKONT]), null()),
ApplyMap('MapeoCONCEPTOSFBL3N', Num#([G/L Account_HKONT]), NULL())
)))));
i needed to split the concepts in cxc,cxp and fbl3n, thats what i did this, in
pls post a pic of your DM
this line is incorrect:
'Gastos de Administración, Comerciales y Generales','GASTOS DE ADMINISTRACION'
it has to be two lines:
Gastos de Administración, GASTOS DE ADMINISTRACION
Comerciales y Generales,GASTOS DE ADMINISTRACION
and because conceptoInline its my refer dimension to this, i need to compare when ConceptoInline iqual to 'Ventas Netas' use the CONCEPTO that match with de account ConceptoInline it just a reference is not associate to anytable
the point is if the association between the two fields is correct lik will handle the comparison for you
not sure why you need to store values in a variable during load script - you may have to provide more info to understand what you are doing. also a DM would help, showing the expression for fields that anyone helping you cant see where they are coming from will not help. only you can see what these fields are and weher they are coming from so help others help you