Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
paulineCom
Helper I
Helper I

DAX Calcular funciton no filtra

Hola

Necesito ayuda en este caso, tengo una tabla XVENTES (en consulta directa) bruja contiene una fecha (DateEve) y una columna ValEur. Quiero comparar los resultados del mes anterior y el real, ya he creado la medida de que sumar el ValEur para el mes curent.

ahora necesito tomar la suma de ValEur en un período de tiempo que comienza con un mesure y termina con otro.

A continuación tienes mi sintaxis dax para mi CA month-1, y es apparenlty ignorando mi filtro basado en las dos fechas.

La sintaxis de las dos medidas que devuelven mis límites de fechas están a continuación,

CA Month-1 =
CALCULATE( sum(XVENTES[ValEur]), 
                                     DATESBETWEEN(XVENTES[DateEve],
                                                         [Date_month_str-1],
                                                         [Date_month_end-1]))

//end date (it's another mesure)
Date_month_end-1 = 
DATE(YEAR(LASTDATE(XVENTES[DateEve])),
          MONTH(LASTDATE(XVENTES[DateEve]))-1,
          DAY(LASTDATE(XVENTES[DateEve])))

//starting date (it's another mesure)
Date_month_str-1 = 
DATE(YEAR(LASTDATE(XVENTES[DateEve])),
          MONTH(LASTDATE(XVENTES[DateEve]))-1,
          1)

Mi filtro está siendo ignorado, no sé por qué

¿Qué estoy haciendo mal?

Cualquier ayuda es apreciada. Gracias

saludos.

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hola @paulineCom ,

Debe crear una tabla de calendario no relacionada como una segmentación de datos.

Aquí está el ejemplo .pbix

Saludos
Liang
Si este post ayuda, entonces considera Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

View solution in original post

5 REPLIES 5
V-lianl-msft
Community Support
Community Support

Hola @paulineCom ,

Debe crear una tabla de calendario no relacionada como una segmentación de datos.

Aquí está el ejemplo .pbix

Saludos
Liang
Si este post ayuda, entonces considera Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Thank you @V-lianl-msft it helped me a lot.

 

I'm not sure to understand how could it work with this table date unlinked to the sales table.

I've understand the dax function, it is really clear.

 

Sales[Date] <= MAX ( DimDate[Date] )
I ignored that would be possible. I mean, it's unlinked. 
 
Many thanks for the example you gave me.
amitchandak
Super User
Super User

@paulineCom , Usted debe salir con la tabla para la inteligencia de todos los tiempos

Usted puede obtener este mes vs el último como estos ejemplos


MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
this month =MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH('Date'[Date])))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
previous month value =  CALCULATE(sum(''Table''[total hours value]),previousmonth('Date'[Date]))

diff = [MTD Sales]-[last MTD Sales]
diff % = divide([MTD Sales]-[last MTD Sales],[last MTD Sales])

//Without TI 
Month Rank = RANKX(all('Date'),'Date'[Month],,ASC,Dense)	
This Month = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])))
Last Month = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=max('Date'[Month Rank])-1))
Last year Month= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Month Rank]=(max('Date'[Month Rank]) -12)))

for exemple the 

 

 CALCULATE(SUM(XVENTES[ValEur]),DATESMTD(DimDate[Date]))

 

doen't return any results. 

 

Maybe it's beacause my dimDate is not created correctly, here is the way I did it :

 

DimDate = ADDCOLUMNS(
    CALENDAR(DATE(YEAR(TODAY())-10,1,1),DATE(YEAR(TODAY())+1,12,31)),
    "DateEve", FORMAT([Date], "DD/MM/YYYY"),
    "Année", YEAR([Date]),
    "NoMois", MONTH([Date]),
    "Mois", FORMAT([Date], "MM"),
    "NoJour", WEEKDAY([Date]),
    "Jour", FORMAT([Date], "DD"),
    "Trimestre", FORMAT([Date], "TQ")
)

is there anything else i should to to make it work ? 

Hello, thank you for helping me,

 

i've tried this to calculate my valEur on last month (wich is 01/08/2020 to 01/28/2020)

 

 

CA Month-1 = CALCULATE( sum(XVENTES[ValEur]), DATESMTD(ENDOFMONTH(DATEADD(XVENTES[DateEve],-1,MONTH))))

 

 
but i have some errors in my visualisation, saying : "the function DATEADD wait a contiguous selection when the date column ist'n unique, is discontinuous or contains an hour part.
 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors