The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hola, me gustaría crear un gráfico de columnas agrupadas como este:
Donde para cada columna (el eje X es una máquina) la primera columna muestra un valor para hace 1 mes, la segunda hace 2 meses y la tercera hace 3 meses. Si un usuario establece una segmentación yearmonth en abril de 2025, la primera columna debe mostrar marzo de 2025, la segunda - febrero de 2025 y la tercera - enero de 2025.
Así es como se ven mis datos:
Ya está sin pivote.
¿Podrías ayudarme, por favor? ¡Gracias!
Hola
Pruebe este enfoque.
Total = suma(Datos[Valor])
Total en PM = calcular([Total],mesanterior(calendario[fecha]))
Total en P2PM = calcular([Total en PM],mesanterior(calendario[fecha]))
Total en P2P2PM = calculate([Total en P2PM],previousmonth(calendar[date]))
Espero que esto ayude.
¡Eso parece ser todo!
Puede crear una medida
no funciona
Sugiero la siguiente solución:
Supongamos que tienes un filtro para el año y para el mes. Tendremos que llamarlos para saber cuál es el valor. Lo ponemos en formato de fecha y para que sea más fácil siempre tomamos el primer día del mes. A continuación, calculamos el final del mes -1 (mes anterior) y luego tomamos la suma del valor donde el año y el mes son iguales al mes anterior seleccionado. Y eliminamos el filtro de fecha tenue para que no nos limitemos a abril.
PYMonth =
var _EOMonth = EOMONTH(DATE(SELECTEDVALUE('DIM Date'[Year]),SELECTEDVALUE('DIM Date'[MonthNumber]),1),-1)
return
CALCULATE(SUM('Table'[Value]),REMOVEFILTERS('DIM Date'), YEAR(_EOMonth)= YEAR('Table'[Date]),month(_EOMonth)= month('Table'[Date]))
PYMonth-1 =
var _EOMonth = EOMONTH(DATE(SELECTEDVALUE('DIM Date'[Year]),SELECTEDVALUE('DIM Date'[MonthNumber]),1),-2)
return
CALCULATE(SUM('Table'[Value]),REMOVEFILTERS('DIM Date'), YEAR(_EOMonth)= YEAR('Table'[Date]),month(_EOMonth)= month('Table'[Date]))
PYMonth-2 =
var _EOMonth = EOMONTH(DATE(SELECTEDVALUE('DIM Date'[Year]),SELECTEDVALUE('DIM Date'[MonthNumber]),1),-3)
return
CALCULATE(SUM('Table'[Value]),REMOVEFILTERS('DIM Date'), YEAR(_EOMonth)= YEAR('Table'[Date]),month(_EOMonth)= month('Table'[Date]))
// Dynamic measure for 1 month ago Value 1 Month Ago = VAR SelectedDate = SELECTEDVALUE('Date'[Date], MAX('Date'[Date])) // Gets selected date or most recent VAR OneMonthAgo = EOMONTH(SelectedDate, -1) VAR FirstDayOfMonth = EOMONTH(OneMonthAgo, -1) + 1 VAR LastDayOfMonth = OneMonthAgo RETURN CALCULATE( SUM('YourTable'[Value]), FILTER( ALL('Date'), 'Date'[Date] >= FirstDayOfMonth && 'Date'[Date] <= LastDayOfMonth ) ) // Dynamic measure for 2 months ago Value 2 Months Ago = VAR SelectedDate = SELECTEDVALUE('Date'[Date], MAX('Date'[Date])) VAR TwoMonthsAgo = EOMONTH(SelectedDate, -2) VAR FirstDayOfMonth = EOMONTH(TwoMonthsAgo, -1) + 1 VAR LastDayOfMonth = TwoMonthsAgo RETURN CALCULATE( SUM('YourTable'[Value]), FILTER( ALL('Date'), 'Date'[Date] >= FirstDayOfMonth && 'Date'[Date] <= LastDayOfMonth ) ) // Dynamic measure for 3 months ago Value 3 Months Ago = VAR SelectedDate = SELECTEDVALUE('Date'[Date], MAX('Date'[Date])) VAR ThreeMonthsAgo = EOMONTH(SelectedDate, -3) VAR FirstDayOfMonth = EOMONTH(ThreeMonthsAgo, -1) + 1 VAR LastDayOfMonth = ThreeMonthsAgo RETURN CALCULATE( SUM('YourTable'[Value]), FILTER( ALL('Date'), 'Date'[Date] >= FirstDayOfMonth && 'Date'[Date] <= LastDayOfMonth ) )
no funciona