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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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)))
Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors
Top Kudoed Authors