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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
av9
Helper III
Helper III

Calcular el valor de fecha para la fecha anterior a la fecha MAX

Hola, En mi modelo tengo datos de ventas que se rellenan para cada país en diferentes momentos del mes. Por lo tanto, puedo tener datos para el país 'Bélgica' en '31 Oct' pero Noruega será '30 Sep'.

Así que utilizo la última fecha de venta para calcular las ventas totales de cada país;

Fecha de actualización del país: CALCULATE(MAX(Sales[Date]), REMOVEFILTERS(Customer[Customer]))
Importe de ventas de suma ?
Calcular
( SUMX(VALUES(Country[Country]),SUM(Sales[Amount])),FILTER(Sales, (MAX(Sales[Date])-[Country Refresh Date])))

Si quiero ver los datos de ventas de los meses anteriores, ¿cómo calculo el mes anterior en función de la fecha de la última fecha de actualización del país por país?

Se adjunta el PBIX que estoy usando.

https://drive.google.com/file/d/1OvSLP05PXI7ZGEkwYC5KQFJ_9qhbQMaq/view?usp=sharing

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@av9 , Probar medidas como


Importe de ventas de suma ?
Calcular
( SUMX(VALUES(Country[Country]),SUM(Sales[Amount])),FILTER(Sales,Sales[Date]-CALCULATE(max(Sales[Date]),ALLEXCEPT(Country,Country[Country]))))

El último mes de La cantidad de ventas ?
Calcular
( SUMX(VALUES(Country[Country]),SUM(Sales[Amount])),FILTER(Sales,Sales[Date]-eomonth(CALCULATE(max(Sales[Date]),ALLEXCEPT(Country,Country[Country])),-1)))

O

Importe de ventas de suma ?
Calcular
( SUMX(VALUES(Country[Country]),SUM(Sales[Amount])),FILTER(Sales,eomonth(Sales[Date],0)-CALCULATE(max(Sales[Date]),ALLEXCEPT(Country,Country[Country]))))

El último mes de La cantidad de ventas ?
Calcular
( SUMX(VALUES(Country[Country]),SUM(Sales[Amount])),FILTER(Sales,eomonth(Sales[Date],0)-eomonth(CALCULATE(max(Sales[Date]),ALLEXCEPT(Country,Country[Country])),-1)))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@av9 , Probar medidas como


Importe de ventas de suma ?
Calcular
( SUMX(VALUES(Country[Country]),SUM(Sales[Amount])),FILTER(Sales,Sales[Date]-CALCULATE(max(Sales[Date]),ALLEXCEPT(Country,Country[Country]))))

El último mes de La cantidad de ventas ?
Calcular
( SUMX(VALUES(Country[Country]),SUM(Sales[Amount])),FILTER(Sales,Sales[Date]-eomonth(CALCULATE(max(Sales[Date]),ALLEXCEPT(Country,Country[Country])),-1)))

O

Importe de ventas de suma ?
Calcular
( SUMX(VALUES(Country[Country]),SUM(Sales[Amount])),FILTER(Sales,eomonth(Sales[Date],0)-CALCULATE(max(Sales[Date]),ALLEXCEPT(Country,Country[Country]))))

El último mes de La cantidad de ventas ?
Calcular
( SUMX(VALUES(Country[Country]),SUM(Sales[Amount])),FILTER(Sales,eomonth(Sales[Date],0)-eomonth(CALCULATE(max(Sales[Date]),ALLEXCEPT(Country,Country[Country])),-1)))

Las medidas no funcionaron como se esperaba, pero sí dio la idea de usar Eomnth para calcular el mes anterior a partir de la fecha máxima.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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