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
Syndicate_Admin
Administrator
Administrator

Quitar el último mes del intervalo de fechas

Hola, chicos

Tengo una medida que cuenta el número de facturas en acumulativo con la función DATESYTD que van al 30/09.

count cumul =  CALCULATE(DISTINCTCOUNT(Invoice[N° Invoice]),DATESYTD('Date'[Date],"30/09"))

la tabla fecha es = calendar(min(Invoice[° Invoice],today())

Existe una relación entre factura y fecha

El usuario puede filtrar por año y por mes. Si no se utiliza ninguno de los filtros, la medida se calcularán hasta la última fecha de la tabla Fecha.

si la fecha seleccionada es en el mismo mes y año de hoy(), me gustaría que calculara hasta el último día del último mes de hoy por lo que agregué otro filtro en el cálculo

count cumul 2 = 

var max_date = MAX('Date'[Date])

var date_a = DATE(YEAR(max_date),MONTH(max_date)-1,EOMONTH(max_date,-1))

var result = IF(MONTH(max_date)=MONTH(TODAY()) && YEAR(max_date)=YEAR(TODAY()),
CALCULATE(DISTINCTCOUNT(Invoice[N° Invoice]),DATESYTD('Date'[Date],"30/09"),
          FILTER('Date','Date'[Date]<= date_a))
,CALCULATE(DISTINCTCOUNT(Invoice[N° Invoice]),DATESYTD('Date'[Date],"30/09")))

return result

pero no funciona, ¿puedes decirme qué pasa?

Aquí está el resultado que me gustaría obtener. Valor vacío en lugar de 23 237 en septiembre/2021

trungnguyen0000_0-1632152846786.png

Segunda pregunta: Si me gustaría calcular en un período específico, ¿puedo usar Filter(Date, Range of date) después de DatesYTD?

¡Muchas gracias!

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

El problema puede deberse a "date_a".

Intente modificar :
var date_a = EOMONTH(TODAY(),-1)

Vlianlmsft_0-1632389179316.png

Syndicate_Admin
Administrator
Administrator

Hola

Gracias, pero esta medida no cuenta en acumulativo

Aquí está el resultado de esta medida en la 3ª columna

trungnguyen0000_0-1632213634575.png

se detiene en agosto de 2021

Syndicate_Admin
Administrator
Administrator

@trungnguyen0000 , Prueba como

recuento acumulado 2 =
var _max1 = MAXX(allselected('Date'), 'Date'[Date])
var _max = eomonth(_max1.0)

var _today = eomonth(today(),0)

var result = IF(_max = _today,
CALCULATE(DISTINCTCOUNT(Factura[N° Factura]),DATESYTD('Fecha'[Fecha],"30/09"),
FILTER('Fecha','Fecha'[Fecha]<= eomonth(_max1,-1)))
,CALCULATE(DISTINCTCOUNT(Factura[N° Factura]),DATESYTD('Fecha'[Fecha],"30/09")))

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.