The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Trato de calcular:
Total SR-ID por mes (fácil)
Total SR-ID nuevo (ID de recuento que anteriormente no estaban disponibles en todos los meses anteriores)
Total SR-ID antiguo (ID de recuento que estaban disponibles en el último mes, pero ya no en el mes actual)
Para eso agregué un INDEX a la tabla que tiene el YearMonth que uso:
Index = COUNTROWS( FILTER(VALUES(BridgePeriod[YearMonth]); BridgePeriod[YearMonth] < EARLIER(BridgePeriod[YearMonth]) ))
Y utilizo las siguientes medidas DAX:
Medida 1 SR-ID Nuevo
COUNT SR-ID NEW =
VAR Ids = VALUES(CUSTAMOUNTREPORTTABLE[SR-ID])
VAR LastMonthIDs = CALCULATETABLE(VALUES(CUSTAMOUNTREPORTTABLE[SR-ID]);
FILTER( ALL(BridgePeriod); 'BridgePeriod'[Index] = SELECTEDVALUE('BridgePeriod'[Index]) -1))
Return CALCULATE( COUNTROWS( EXCEPT(Ids; LastMonthIDs)); CUSTAMOUNTREPORTTABLE[SR-ID] <> "")
Medida 2 SR-ID OLD
COUNT SR-ID OLD =
VAR Ids = VALUES(CUSTAMOUNTREPORTTABLE[SR-ID])
VAR LastMonthIDs = CALCULATETABLE(VALUES(CUSTAMOUNTREPORTTABLE[SR-ID]);
FILTER( ALL(BridgePeriod); 'BridgePeriod'[Index] = SELECTEDVALUE('BridgePeriod'[Index]) -1))
Return CALCULATE( COUNTROWS( EXCEPT(LastMonthIDs; Ids));CUSTAMOUNTREPORTTABLE[SR-ID] <> "")
Medida 3 SR-ID Total
COUNT SR-ID TOTAL =
CALCULATE( DISTINCTCOUNT(CUSTAMOUNTREPORTTABLE[Customer-ID]);
CUSTAMOUNTREPORTTABLE[Total]>0;
CUSTAMOUNTREPORTTABLE[Bedrijf]="001";
CUSTAMOUNTREPORTTABLE[SR-ID] <> "" )
Con el índice y las medidas anteriores esperaba contar por mes agregado/eliminado ID, pero de alguna manera no muestra nada cerca de lo que esperaba. El conjunto de datos se incluye en el archivo PowerBI, vínculo siguiente.
Tenga en cuenta que EL CUSTAMOUNTREPORTTABLE tiene un montón de filas, mucho menos que el SR-ID. Es por eso que filtro para CUSTAMOUNTREPORTTABLE[SR-ID] <> ""
Agregué el vínculo al archivo de Power BI
https://1drv.ms/u/s!AliMmiR5bX0C3G0xfHLYruem4rQh?e=q1w98c
¿Alguna sugerencia?
Con estas medidas, usted debe ser capaz de encontrar con el grupo por SR ID
This month = calculate(countrows(CUSTAMOUNTREPORTTABLE),filter(BridgePeriod, BridgePeriod[Index] =max(BridgePeriod[Index])))
last month = calculate(countrows(CUSTAMOUNTREPORTTABLE),filter(BridgePeriod, BridgePeriod[Index] =max(BridgePeriod[Index])-1))
all month before this = calculate(countrows(CUSTAMOUNTREPORTTABLE),filter(BridgePeriod, BridgePeriod[Index] <max(BridgePeriod[Index])))
Gracias por la respuesta rápida!
Agregué tus medidas también, pero aún así obtengo resultados extraños. Vea la imagen de abajo, o el archivo PBI a continuación:
Imagen:
Archivo PBI:
Hola , @Herasion
¿Qué tiene de malo los datos de resultados presentados, puede mostrar los resultados esperados para las pruebas?
Y hago algunas modificaciones para medir como abajo y muestra el mismo resultado.
COUNT SR-ID NEW =
VAR Ids =
VALUES ( CUSTAMOUNTREPORTTABLE[SR-ID] )
VAR LastMonthIDs =
CALCULATETABLE (
VALUES ( CUSTAMOUNTREPORTTABLE[SR-ID] ),
FILTER (
ALL ( BridgePeriod ),
'BridgePeriod'[Index]
= SELECTEDVALUE ( 'BridgePeriod'[Index] ) - 1
)
)
RETURN
CALCULATE (
COUNTROWS ( EXCEPT ( Ids, LastMonthIDs ) ),
CUSTAMOUNTREPORTTABLE[SR-ID] <> ""
)
COUNT SR-ID OLD =
VAR Ids =
VALUES ( CUSTAMOUNTREPORTTABLE[SR-ID] )
VAR LastMonthIDs =
CALCULATETABLE (
VALUES ( CUSTAMOUNTREPORTTABLE[SR-ID] ),
FILTER (
ALL ( BridgePeriod ),
'BridgePeriod'[Index]
= SELECTEDVALUE ( 'BridgePeriod'[Index] ) - 1
)
)
RETURN
CALCULATE (
COUNTROWS ( EXCEPT ( LastMonthIDs, Ids ) ),
CUSTAMOUNTREPORTTABLE[SR-ID] <> ""
)
Aquí está la demostración.
Saludos
Equipo de Apoyo Comunitario _ Eason
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.