Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Estoy tratando de encontrar la fórmula para tomar el valor de la suma de la última fecha del último mes, mientras que logró tomar la última fecha, pero el valor de la suma no parece coincidir con el número real de mi hoja.
Resultado esperado: 132.240
Resultado final: 132.163
¿Me perdí algo? No podía entender dónde salió mal.
LastDateSumAudience =
VAR LastDateOfMonth =
CALCULATE(
MAX('Follower'[Date]), //finds the last date in each month
ALLEXCEPT('Follower', 'Follower'[Month]) //ensures that the calculation happens within each month
)
RETURN
CALCULATE(
SUM('Follower'[Audience]), 'Follower'[Date] = LastDateOfMonth
//sums only the rows where the date matches the last date of that month
)
Fecha | Red | Audiencia |
31/1/2025 | X | 68 |
31/1/2025 | X | 83 |
31/1/2025 | X | 103 |
31/1/2025 | Facebook (en inglés) | 28,869 |
31/1/2025 | Facebook (en inglés) | 5,814 |
31/1/2025 | Facebook (en inglés) | 57,545 |
31/1/2025 | Facebook (en inglés) | 288 |
31/1/2025 | Instagram (en inglés) | 1,896 |
31/1/2025 | Instagram (en inglés) | 1,434 |
31/1/2025 | Instagram (en inglés) | 252 |
31/1/2025 | Instagram (en inglés) | 246 |
31/1/2025 | 12,177 | |
31/1/2025 | 1,224 | |
31/1/2025 | 9,659 | |
31/1/2025 | 110 | |
31/1/2025 | YouTube (en inglés) | 11,500 |
31/1/2025 | YouTube (en inglés) | 972 |
Solved! Go to Solution.
ACTUALIZACIONES: finalmente encontró el problema, se debió al formato de fecha que no pudo capturar todo el valor correcto. Quité la tabla original de Power BI y la volví a importar, cambié el tipo de datos en la columna de fecha a texto, luego cambié el tipo de > usando la configuración regional > cambiar al formato de fecha local, y finalmente pudo obtener elresultado esperado: 132,240
ACTUALIZACIONES: finalmente encontró el problema, se debió al formato de fecha que no pudo capturar todo el valor correcto. Quité la tabla original de Power BI y la volví a importar, cambié el tipo de datos en la columna de fecha a texto, luego cambié el tipo de > usando la configuración regional > cambiar al formato de fecha local, y finalmente pudo obtener elresultado esperado: 132,240
Hola @fksng66
No veo una columna de mes en los datos de muestra. Así que agregué y la medida funciona perfectamente.
Hola @fksng66 ,
La medida de DAX está bien estructurada, pero es probable que la discrepancia surja de cómo se determina LastDateOfMonth. Es posible que el uso de ALLEXCEPT('Follower', 'Follower'[Month]) no filtre correctamente la última fecha del mes cuando se aplica en el CALCULATE final. En lugar de confiar en ALLEXCEPT, intente asegurarse de que siempre está filtrando para el último mes y sumando los valores solo para esa última fecha.
LastDateSumAudience =
VAR LatestMonth =
MAXX(ALL('Follower'), 'Follower'[Month]) // Finds the latest month in the dataset
VAR LastDateOfLatestMonth =
MAXX(
FILTER(ALL('Follower'), 'Follower'[Month] = LatestMonth),
'Follower'[Date]
) // Finds the last date in the latest month
RETURN
CALCULATE(
SUM('Follower'[Audience]),
'Follower'[Date] = LastDateOfLatestMonth
)
Este enfoque garantiza que MAXX(ALL('Follower'), 'Follower'[Month]) identifique correctamente el último mes, luego MAXX(FILTER(ALL('Follower'), 'Follower'[Month] = LatestMonth), 'Follower'[Date]) encuentre la última fecha dentro de ese mes y, finalmente, SUM('Follower'[Audience]) se filtra para esa última fecha específica.
Si la discrepancia persiste, considere la posibilidad de usar SUMX para la evaluación de nivel de fila para confirmar que se están sumando todos los valores esperados:
LastDateSumAudience_SUMX =
VAR LatestMonth =
MAXX(ALL('Follower'), 'Follower'[Month]) // Ensures the calculation is independent of filters
VAR LastDateOfLatestMonth =
MAXX(
FILTER(ALL('Follower'), 'Follower'[Month] = LatestMonth),
'Follower'[Date]
) // Finds the last date within the latest month
RETURN
SUMX(
FILTER(ALL('Follower'), 'Follower'[Date] = LastDateOfLatestMonth),
'Follower'[Audience]
)
Esta versión recorre explícitamente las filas filtradas mediante SUMX, lo que garantiza que solo se incluyan en la suma las filas correspondientes a la última fecha. Al aplicar ALL('Follower'), el cálculo permanece independiente de los filtros existentes en el objeto visual, lo que reduce las posibilidades de que falten valores. Si los números siguen sin coincidir, compruebe el conjunto de datos para ver si hay valores duplicados, filtros inesperados o datos que faltan.
Saludos
He probado ambos métodos, incluidos los otros que han publicado aquí, pero desafortunadamente todavía da los mismos 132,163 en su lugar.
Aunque intenté agregar una nueva fila con una cifra grande para ver si se recuperaba, pero no lo hizo, por derecho debería obtener 232,240 con la nueva fila, pero el número aún recordaba lo mismo.
Fecha | Red | Audiencia |
31/1/2025 | X | 68 |
31/1/2025 | x | 100000 |
31/1/2025 | X | 83 |
31/1/2025 | X | 103 |
31/1/2025 | Facebook (en inglés) | 28,869 |
31/1/2025 | Facebook (en inglés) | 5,814 |
31/1/2025 | Facebook (en inglés) | 57,545 |
31/1/2025 | Facebook (en inglés) | 288 |
31/1/2025 | Instagram (en inglés) | 1,896 |
31/1/2025 | Instagram (en inglés) | 1,434 |
31/1/2025 | Instagram (en inglés) | 252 |
31/1/2025 | Instagram (en inglés) | 246 |
31/1/2025 | 12,177 | |
31/1/2025 | 1,224 | |
31/1/2025 | 9,659 | |
31/1/2025 | 110 | |
31/1/2025 | YouTube (en inglés) | 11,500 |
31/1/2025 | YouTube (en inglés) | 972 |
@Rupak_bi @Bibiano_Geraldo revisé el panel de filtro y el filtro se borró, no se aplicó ningún filtro. Sin embargo, cuando intenté marcar para filtrar solo mostrar 31/1/2025 en la columna de fecha en el editor de consultas, pudo mostrar el número correcto.
Ver
Lo que siento, su función "todo excepto" puede crear el problema. Si ya está utilizando month como segmentación, este "allexcept" no es necesario. Inténtalo una vez.
VAR LastDateOfMonth =
CALCULATE(
MAX('Follower'[Date])) //finds the last date in each month
no funcionó. Sigue siendo lo mismo.
Comparta algunos datos de muestra más que representen exactamente la tabla real. Si la tabla real tiene datos de varios años, inclúyalo. Actualmente, los datos de muestra que compartió solo tienen entradas de fecha única.
Aquí he incluido los datos del 1 de enero, espero que sean suficientes para que trabajéis.
https://drive.google.com/file/d/151jDLK88b1cTfY0WApRBHptPzmd6bmg0/view?usp=sharing
Aquí he incluido los datos del 28 de enero, no pude copiar toda la tabla del 1 de enero debido al límite de número de palabras. Espero que sea suficiente para que trabajes.
Canal | Año | Cuarto | Mes | Fecha | Audiencia |
X | 2025 | Pregunta 1 | Ene | 28/1/2025 | 68 |
X | 2025 | Pregunta 1 | Ene | 28/1/2025 | 83 |
X | 2025 | Pregunta 1 | Ene | 28/1/2025 | 103 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 28/1/2025 | 28,875 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 28/1/2025 | 5,773 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 28/1/2025 | 57,547 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 28/1/2025 | 289 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 28/1/2025 | 1,897 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 28/1/2025 | 1,433 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 28/1/2025 | 253 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 28/1/2025 | 246 |
2025 | Pregunta 1 | Ene | 28/1/2025 | 12,174 | |
2025 | Pregunta 1 | Ene | 28/1/2025 | 1,226 | |
2025 | Pregunta 1 | Ene | 28/1/2025 | 9,654 | |
2025 | Pregunta 1 | Ene | 28/1/2025 | 111 | |
YouTube (en inglés) | 2025 | Pregunta 1 | Ene | 28/1/2025 | 11,500 |
YouTube (en inglés) | 2025 | Pregunta 1 | Ene | 28/1/2025 | 971 |
X | 2025 | Pregunta 1 | Ene | 29/1/2025 | 68 |
X | 2025 | Pregunta 1 | Ene | 29/1/2025 | 83 |
X | 2025 | Pregunta 1 | Ene | 29/1/2025 | 103 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 29/1/2025 | 28,873 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 29/1/2025 | 5,784 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 29/1/2025 | 57,547 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 29/1/2025 | 288 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 29/1/2025 | 1,897 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 29/1/2025 | 1,434 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 29/1/2025 | 253 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 29/1/2025 | 246 |
2025 | Pregunta 1 | Ene | 29/1/2025 | 12,173 | |
2025 | Pregunta 1 | Ene | 29/1/2025 | 1,225 | |
2025 | Pregunta 1 | Ene | 29/1/2025 | 9,658 | |
2025 | Pregunta 1 | Ene | 29/1/2025 | 111 | |
YouTube (en inglés) | 2025 | Pregunta 1 | Ene | 29/1/2025 | 11,500 |
YouTube (en inglés) | 2025 | Pregunta 1 | Ene | 29/1/2025 | 972 |
X | 2025 | Pregunta 1 | Ene | 30/1/2025 | 68 |
X | 2025 | Pregunta 1 | Ene | 30/1/2025 | 83 |
X | 2025 | Pregunta 1 | Ene | 30/1/2025 | 103 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 30/1/2025 | 28,871 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 30/1/2025 | 5,814 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 30/1/2025 | 57,548 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 30/1/2025 | 288 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 30/1/2025 | 1,897 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 30/1/2025 | 1,434 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 30/1/2025 | 253 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 30/1/2025 | 246 |
2025 | Pregunta 1 | Ene | 30/1/2025 | 12,175 | |
2025 | Pregunta 1 | Ene | 30/1/2025 | 1,226 | |
2025 | Pregunta 1 | Ene | 30/1/2025 | 9,654 | |
2025 | Pregunta 1 | Ene | 30/1/2025 | 111 | |
YouTube (en inglés) | 2025 | Pregunta 1 | Ene | 30/1/2025 | 11,500 |
YouTube (en inglés) | 2025 | Pregunta 1 | Ene | 30/1/2025 | 972 |
X | 2025 | Pregunta 1 | Ene | 31/1/2025 | 68 |
X | 2025 | Pregunta 1 | Ene | 31/1/2025 | 100000 |
X | 2025 | Pregunta 1 | Ene | 31/1/2025 | 83 |
X | 2025 | Pregunta 1 | Ene | 31/1/2025 | 103 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 31/1/2025 | 28,869 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 31/1/2025 | 5,814 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 31/1/2025 | 57,545 |
Facebook (en inglés) | 2025 | Pregunta 1 | Ene | 31/1/2025 | 288 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 31/1/2025 | 1,896 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 31/1/2025 | 1,434 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 31/1/2025 | 252 |
Instagram (en inglés) | 2025 | Pregunta 1 | Ene | 31/1/2025 | 246 |
2025 | Pregunta 1 | Ene | 31/1/2025 | 12,177 | |
2025 | Pregunta 1 | Ene | 31/1/2025 | 1,224 | |
2025 | Pregunta 1 | Ene | 31/1/2025 | 9,659 | |
2025 | Pregunta 1 | Ene | 31/1/2025 | 110 | |
YouTube (en inglés) | 2025 | Pregunta 1 | Ene | 31/1/2025 | 11,500 |
YouTube (en inglés) | 2025 | Pregunta 1 | Ene | 31/1/2025 | 972 |
A continuación, compruebe si hay algún filtro subyacente.
Tal vez tenga algunos filtros en su panel que excluyen algunos valores, verifique dos veces sus filtros.
@fksng66 , Intente usar
DAX
LastDateSumAudience =
VAR LastDateOfMonth =
CALCULAR(
LASTDATE('Seguidor'[Fecha])
)
DEVOLUCIÓN
CALCULAR(
SUM('Seguidor'[Audiencia]),
'Seguidor'[Fecha] = ÚltimaFechaDeMes
)
Hola @fksng66 ,
Por favor, pruebe esto:
LastDateSumAudience =
VAR LastDateOfMonth =
CALCULATE(
MAX('Follower'[Date]),
ALLEXCEPT('Follower', 'Follower'[Month])
)
RETURN
CALCULATE(
SUM('Follower'[Audience]),
FILTER(
ALL('Follower'),
INT('Follower'[Date]) = INT(LastDateOfMonth)
)
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.