Forum Discussion
Data from a table (count and sum)
I think we are not understanding each other and I think I also got confused in one of the answers...
Forget option 1 and 2 because I already have them, I attached a screenshot of where you can see them.
Now I am missing 3 and 4, if you look at the screenshot, in the table below, the total says 6, it is not correct, what I want is the sum that according to the screenshot should be 14 if I have not counted wrong.
On the other hand, apart from the total sum, I want the count of days, according to the attached table it should be 11 (these are the days with at least 1 record)
I don't know if the captures have made it better understood.
Thank you.
Hola @Syndicate_Admin ,
Es una situación relativamente común que la medida en el total sea incorrecta, la medida sigue el contexto de la fila "Total" y se calcula en ese contexto. Por lo tanto, las medidas utilizadas en las columnas de visualizaciones de tabla pueden tener valores inesperados en la columna Total.
Puede utilizar las siguientes medidas, utilizar la función IF() + ISINSCOPE() para determinar el nivel de datos y, a continuación, realizar diferentes cálculos en función del nivel.
La medida 2 se puede modificar para:
Measure 2 =
VAR _count = CALCULATE(COUNT('Table'[No]),FILTER(ALL('Table'),'Table'[Date] = MAX('Table'[Date])))
VAR _total_count = COUNT('Table'[No])
RETURN
IF(ISINSCOPE('Table'[Date]),_count,_total_count)
Si desea calcular el número de días con al menos 1 registro, puede modificar el compás 4 para:
Measure 4 =
CALCULATE(DISTINCTCOUNT('Table'[Date]),FILTER(ALL('Table'),'Table'[Measure 2] >= 1))
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.
- apenaranda2 years ago
Post Partisan
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.- Syndicate_Admin2 years ago
Administrator
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 countsSi 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]))