Forum Discussion
Data from a table (count and sum)
Could you briefly explain Measure 2 to me, I don't really understand what they do.
Anyway, I see that it doesn't add up, Measure 2 says that on 01/01/2024 there are three different users when there are only two (user 1 and 2)
Measure 4 is already clear to me and it is correct.
Hola @Syndicate_Admin ,
Modifiqué la medida 2 y agregué algunos comentarios más.
Measure 2 =
VAR _count = CALCULATE(DISTINCTCOUNT('Table'[Cod. User]),FILTER(ALL('Table'),'Table'[Date] = MAX('Table'[Date]))) //Counts the different user codes for the current date
VAR _table = SUMMARIZE('Table','Table'[Date],'Table'[Cod. User]) // Create virtual table to get table with unique date and user code values
VAR _total_count = COUNTROWS(_table) // Count the number of rows in the virtual table
RETURN
IF(ISINSCOPE('Table'[Date]),_count,_total_count) // Display different data in layers, date layer and total layer display different counts
Si su período actual no se refiere a esto, por favor aclárelo en una respuesta de seguimiento.
Saludos
Clara Gong
Si esta publicación ayuda, considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
Puede encontrar más información sobre la función ISINSCOPE en la documentación: Función ISINSCOPE (DAX) - DAX | Microsoft Learn.
- apenaranda2 years ago
Post Partisan
Sorry, I don't understand the VAR _count part when you add the
FILTER(ALL('Table'),'Table'[Date] = MAX('Table'[Date]))- Syndicate_Admin2 years ago
Administrator
Hola @Syndicate_Admin ,
La columna calculada puede obtener directamente el valor actual, pero meausre requiere una función agregada como max() para obtener el valor actual. Por lo tanto, al realizar operaciones de cálculo de grupo, measure debe usar la función max para obtener el valor actual y solo se calcularán los mismos valores juntos.
Saludos
Clara Gong
Si esta publicación ayuda, considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
- apenaranda2 years ago
Post Partisan
In my real case, I have the table and the date column is related to a date table.
So should I put this last part like this?
FILTER(ALL(Cab_act_almacen_reg_sql),Cab_act_almacen_reg_sql[Registering Date] = MAX(Fechas[Date]))Table Cab_act_almacen_reg_sql would be the one for records
Dates[Date] would be the dates related to Cab_act_almacen_reg_sql[Registering Date]If I do as I attached, the total does not do it correctly, yes by rows but the total does as before.
Here is all my measure:
Measura 2 = VAR _count = CALCULATE(DISTINCTCOUNT(Cab_act_almacen_reg_sql[Cod_ operario almacen]),FILTER(ALL(Cab_act_almacen_reg_sql),Cab_act_almacen_reg_sql[Registering Date] = MAX(Fechas[Date]))) //Counts the different user codes for the current date VAR _table = SUMMARIZE(Cab_act_almacen_reg_sql,Cab_act_almacen_reg_sql[Cod_ operario almacen]) // Create virtual table to get table with unique date and user code values VAR _total_count = COUNTROWS(_table) // Count the number of rows in the virtual table RETURN IF(ISINSCOPE(Fechas[Date]),_count,_total_count) // Display different data in layers, date layer and total layer display different countsThank you.