Forum Discussion
Data from a table (count and sum)
Hello, I have the following table as data
| No | Fecha | Cod. User |
| 1 | 01/01/2024 | 1 |
| 2 | 01/01/2024 | 1 |
| 3 | 03/01/2024 | 2 |
| 4 | 04/01/2024 | 3 |
| 5 | 05/01/2024 | 3 |
| 6 | 01/01/2024 | 2 |
| 7 | 07/01/2024 | 4 |
| 8 | 08/01/2024 | 6 |
| 9 | 08/01/2024 | 7 |
| 10 | 08/01/2024 | 1 |
| 11 | 11/01/2024 | 1 |
| 12 | 12/01/2024 | 3 |
| 13 | 29/01/2024 | 3 |
| 14 | 30/01/2024 | 4 |
| 15 | 31/01/2024 | 3 |
I need to get a series of data:
1. For each user, how many registrations are there per day?
Example: User 1 has 4 records
2. For each day, know how many different users have records
Example: for the day 1/1/2024 there are 3 records
For 01/08/2024 there are 3 records
3. From data 2, add the amount
Example: following the previous example, the sum would be 3 + 3 = 6
4. count the days when there are records
Example: according to the previous example, the result would be 2 days.
thank you.
12 Replies
- Syndicate_Admin
Administrator
1) Medida = CALCULATE(COUNTROWS('Tabla'), REMOVEFILTERS('Tabla'[No], 'Tabla'[Fecha]))
2) Medida2 = CALCULATE(COUNTROWS('Table'), REMOVEFILTERS('Table'[No], 'Table'[Cód. Usuario]))3) y 4) son un poco confusos- apenaranda
Post Partisan
The measure in point 2 makes the sum of all the registrations for that day, but what I want is to know how many different users there are with registrations that day.
Let's explain it in another way to see if it can be understood better:
Point 3 is basically the sum of records
Point 4, of the entire month (in this example case it is January), how many days there are with at least 1 record, that is, of the 31 days that January has, how many of them there are any records.- Syndicate_Admin
Administrator
3) Las filas de conteo simples deberían ser suficientes
4) Aplique CountRows en la tabla donde la fecha está entre el inicio y el final del mes.
- Syndicate_Admin
Administrator
Hola @Syndicate_Admin ,
Gracias @ChiragGarg2512 por sus respuestas y permítanme darles otra idea:
Para ello, cree una medida.Measure = CALCULATE(COUNT('Table'[No]),FILTER(ALL('Table'),'Table'[Cod. User] = MAX('Table'[Cod. User]))))Measure 2 = CALCULATE(COUNT('Table'[No]),FILTER(ALL('Table'),'Table'[Date] = MAX('Table'[Date]))))Measure 3 = CALCULATE(COUNT('Table'[No]),FILTER(ALL('Table'),'Table'[Measure 2] > 1))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.
- apenaranda
Post Partisan
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.- Syndicate_Admin
Administrator
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.