Forum Discussion

Ivromero's avatar
Ivromero
Regular Visitor
4 years ago

Calculated Column Maxif With Multiple Date Criteria

I need to recreate in Dax the following Formula in order to obtain de Max Value considering multiple date criterias;

 

Excel Formula on Column MAX which has the espected result:

=MAXIFS(E:E;A:A;A2;D:D;"<"&D2;D:D;">="&FECHA.MES(D2;-3))

 

Spected Result:

DocNroCONTACTO FINALEmpresaFecha CicloCONTACTOMAX

DAX RESULT

960421360) Promesa de PagoPO1/7/2022111
960421360) Promesa de PagoPO1/6/2022111
960421360) Promesa de PagoPO1/5/2022101
960421362) Contacto IndirectoPO1/4/2022011
960421363) Sin ContactoPO1/3/2022011
960421365) Sin Contacto - Sistema F9PO1/2/2022011
960421361) Contacto DirectoPO1/1/2022100
960421363) Sin ContactoPO1/12/2021000

 

In Dax Return a wrong value. I implemented this formula;

 

Column = CALCULATE(MAX(MEJOR_CONTACTO[CONTACTO]),
Filter(MEJOR_CONTACTO,MEJOR_CONTACTO[DocNro]=EARLIER(MEJOR_CONTACTO[DocNro])
&&MEJOR_CONTACTO[Fecha Ciclo]<>EARLIER(MEJOR_CONTACTO[Fecha Ciclo])
&&MEJOR_CONTACTO[Fecha Ciclo]<EARLIER(MEJOR_CONTACTO[Fecha Ciclo])
&&MEJOR_CONTACTO[Fecha Ciclo]>=DATEADD(MEJOR_CONTACTO[Fecha Ciclo],-3,MONTH)
&&MEJOR_CONTACTO[Empresa]="POSTA"))