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
Anonymous
Not applicable

El VAR funciona con una fecha constante, pero no en una fórmula

Ya estoy cansado de buscar

Esto funciona en dax:

MySales ?
Informe de VARMonth á month(DATEVALUE("05/01/2020"))
RETURN CALCULATE(SUM(fDespesas[Disp-ndio]); FILTER(dCalendario; MONTH(dCalendario[Fecha])<-ReportingMonth); KEEPFILTERS(fDespesas[Disp-ndio]))
Esto no:
MySales ?
Informe de VARMonth á month(LASTDATE(fDespesas[data]))
RETURN CALCULATE(SUM(fDespesas[Disp-ndio]); FILTER(dCalendario; MONTH(dCalendario[Fecha])<-ReportingMonth); KEEPFILTERS(fDespesas[Disp-ndio]))
Este "month(LASTDATE(fDespesas[data]))" en una medida devuelve 5 pero el uso de "VAR ReportingMonth - 5" también funciona.
Esta variable solo acepta una constante para funcionar bien.
No quiero poner un 5 pero quiero que el DAX calcule ese 5.
¿Alguna solución?
5 REPLIES 5
amitchandak
Super User
Super User

@kkondarzewski , Pruebe este

MySales ?
Informe de VARMonth á month(maxx(allselected(fDespesas),fDespesas[data]))
RETURN CALCULATE(SUM(fDespesas[Disp-ndio]); FILTER(dCalendario; MONTH(dCalendario[Fecha])<-ReportingMonth); KEEPFILTERS(fDespesas[Disp-ndio]))

O


MySales ?
VAR ReportingMonth á calculate(month(LASTDATE(fDespesas[data])))
RETURN CALCULATE(SUM(fDespesas[Disp-ndio]); FILTER(dCalendario; MONTH(dCalendario[Fecha])<-ReportingMonth); KEEPFILTERS(fDespesas[Disp-ndio]))

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
Anonymous
Not applicable

Sólo funcionaba con MAXX. Calcular trajo lo mismo que month_Lastdate.

Icey
Community Support
Community Support

Hola @kkondarzewski ,

Me alegra saber que el problema ha sido resuelto. Usted puede ayudar a aceptar las respuestas que tienen sentido como solución anterior. Su contribución es muy apreciada.

Saludos

Icey

AllisonKennedy
Super User
Super User

Si intenta la siguiente medida en su escenario, ¿qué resultado obtiene?
MySales ?
Informe de VARMonth á month(LASTDATE(fDespesas[data]))
devolución
ReportingMonth

¿No está seguro de si podría funcionar con MAX? https://www.sqlbi.com/blog/marco/2013/10/22/difference-between-lastdate-and-max-for-semi-additive-me...

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Funcionó con MAXX

¡Gracias!

Helpful resources

Announcements
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