Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
SEAM_98
Frequent Visitor

Suma de conteo de registros agrupados.

Buenas, tengo un probrema respecto a la visualización de mi cuadro. Yo quiero que se visualice que por día hubo una visita. Sin embargo como el registro se repite 3 veces porque se visito 3 personas distintas en esa entidad, me sale que la visito como 3 veces cuando en realidad fue una visita.  Por ejemplo, en la entidad Essalud Sabogal el total deberia salirme como 5 visitas y me sale 15 porque en mi tabla la registraron 15 veces. En realidad por el día deberia salirme una visita y al final en el total por la semana de Essalud sabogal 5 visitas.  Intente hacer una medidad de dividir el conteo entre si mismo pero en el total también me bota la unidad y no la suma. No se como hacer porque segun el power bi si hay 15 registros, la visito 15 veces en la semana, cuando en realidad fue 5 veces que visito. Su apoyo por favor.

SEAM_98_0-1702939688838.png

 

1 ACCEPTED SOLUTION

Hi @SEAM_98 ,

 

We can create a measure.

Measure 2 = 

var _table=SUMMARIZE('PRUEBA',Calendario[Mes],'PRUEBA'[EJECUTIVO DE VENTAS],Calendario[Semana del mes],PRUEBA[ENTIDAD],Calendario[Nombre_dia])
var _table2=SUMMARIZE('PRUEBA',Calendario[Mes],'PRUEBA'[EJECUTIVO DE VENTAS],Calendario[Semana del mes],PRUEBA[ENTIDAD])
var _table3=SUMMARIZE('PRUEBA',Calendario[Mes],'PRUEBA'[EJECUTIVO DE VENTAS],Calendario[Semana del mes])
var _table4=SUMMARIZE('PRUEBA',Calendario[Mes],'PRUEBA'[EJECUTIVO DE VENTAS])
var _b=COUNTROWS(FILTER(_table,[Nombre_dia] in VALUES(Calendario[Nombre_dia])))

var _a=SWITCH(TRUE(),
ISINSCOPE(PRUEBA[HORA]),COUNT(PRUEBA[ID]),
ISINSCOPE(Calendario[Nombre_dia]),COUNTROWS(FILTER(_table,[Nombre_dia] in VALUES(Calendario[Nombre_dia]))),
ISINSCOPE(PRUEBA[ENTIDAD]),COUNTROWS(FILTER(_table,[Nombre_dia] in VALUES(Calendario[Nombre_dia]))),
ISINSCOPE('Calendario'[Semana del mes]),SUMX(VALUES(Calendario[Semana del mes]),_b),
ISINSCOPE(PRUEBA[EJECUTIVO DE VENTAS]),SUMX(VALUES(PRUEBA[EJECUTIVO DE VENTAS]),_b),
ISINSCOPE(Calendario[Mes]),SUMX(VALUES(Calendario[Mes]),_b))
return _a

vtangjiemsft_0-1703152883000.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

 

View solution in original post

5 REPLIES 5
v-tangjie-msft
Community Support
Community Support

Hi @SEAM_98 ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1702954006779.png

(2) If you want to display the count of types, create the measure 1.
If you want to display the value of value, but show the total at the subtotal, create measure 2.

Measure 1 = COUNT('Table'[Type4])
Measure 2 = IF(ISINSCOPE('Table'[Type4]),SUM('Table'[value]),[Measure 1])

(3) Then the result is as follows.

vtangjiemsft_1-1702954498885.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi @v-tangjie-msft

I am attaching my table in order to find a solution. For example,  when I create a  matrix visualization. It shows that in monday 11th the seller Jennifer visited 4 times. However, it should be only one visit. Please note I made recount of ID in the visualization. As you can see in the visualization, in monday appears 4 (recount of ID) and I want that shows 1 and Essalud Sabogal the subtotal 4 instead of 13. 

To explain in monday it shows hours from 8:30 am to 11:00 am and visit 4 people but only went to Essalud Sabogal one time. I want that.

 

I am sharing with you the data https://we.tl/t-xocR3oOXzf Remember that it's avalaible only for 7 days.

 

SEAM_98_3-1703002478124.png

SEAM_98_5-1703005422980.png

 

 

 

 

 

 

Hi @SEAM_98 ,

 

We can create a measure.

Measure 2 = 
var _table=SUMMARIZE('PRUEBA',Calendario[Mes],'PRUEBA'[EJECUTIVO DE VENTAS],Calendario[Semana del mes],PRUEBA[ENTIDAD],Calendario[Nombre_dia])
var _table2=SUMMARIZE('PRUEBA',Calendario[Mes],'PRUEBA'[EJECUTIVO DE VENTAS],Calendario[Semana del mes],PRUEBA[ENTIDAD])
var _table3=SUMMARIZE('PRUEBA',Calendario[Mes],'PRUEBA'[EJECUTIVO DE VENTAS],Calendario[Semana del mes])
var _table4=SUMMARIZE('PRUEBA',Calendario[Mes],'PRUEBA'[EJECUTIVO DE VENTAS])
var _a=SWITCH(TRUE(),
ISINSCOPE(Calendario[Nombre_dia]),COUNT(PRUEBA[ID]),
ISINSCOPE(PRUEBA[ENTIDAD]),COUNTROWS(FILTER(_table,[Nombre_dia] in VALUES(Calendario[Nombre_dia]))),
ISINSCOPE('Calendario'[Semana del mes]),COUNTROWS(FILTER(_table2,[ENTIDAD] in VALUES(PRUEBA[ENTIDAD]))),
ISINSCOPE(PRUEBA[EJECUTIVO DE VENTAS]),COUNTROWS(FILTER(_table3,[Semana del mes] in VALUES(Calendario[Semana del mes]))),
ISINSCOPE(Calendario[Mes]),COUNTROWS(FILTER(_table4,[EJECUTIVO DE VENTAS] in VALUES('PRUEBA'[EJECUTIVO DE VENTAS]))))
return _a

vtangjiemsft_0-1703066652909.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Hi friend,

 

I really appreciate your support. Is possible that is in yellow can be 1 instead of 4?.  I made an example from num visit.

 

I made the equations:

 

*month = Seller 1 + Seller 2 + Seller 3

 

*Seller 1 (Jennifer Ramirez) = Semana 3 (10) + Semana 4 ()


*Semana 3 = Asoni Lab (2) + Clinica Ricardo Palma (1) + Essalud Sabogal (4) + Hospital alcides Carrion (1) + INSN San Borja (2) = 10

 

Essalud Sabogal = Lunes (1)  + Martes (1) + Miercoles (1) + Jueves (1) = 4

 

Lunes = Hour 1 (1)  + Hour (1) + ... + Hour (1) = 1

Any day equals to one.

 

 

Day equals to 1

Entity is the sum of days

Week is the sum of entities

Seller is the sum of weeks

Month is the sum of sellers

 

I edit an image how could be.  Only 2 column with values consider. Please your help. 

SEAM_98_2-1703093580845.png

 

 

 

Hi @SEAM_98 ,

 

We can create a measure.

Measure 2 = 

var _table=SUMMARIZE('PRUEBA',Calendario[Mes],'PRUEBA'[EJECUTIVO DE VENTAS],Calendario[Semana del mes],PRUEBA[ENTIDAD],Calendario[Nombre_dia])
var _table2=SUMMARIZE('PRUEBA',Calendario[Mes],'PRUEBA'[EJECUTIVO DE VENTAS],Calendario[Semana del mes],PRUEBA[ENTIDAD])
var _table3=SUMMARIZE('PRUEBA',Calendario[Mes],'PRUEBA'[EJECUTIVO DE VENTAS],Calendario[Semana del mes])
var _table4=SUMMARIZE('PRUEBA',Calendario[Mes],'PRUEBA'[EJECUTIVO DE VENTAS])
var _b=COUNTROWS(FILTER(_table,[Nombre_dia] in VALUES(Calendario[Nombre_dia])))

var _a=SWITCH(TRUE(),
ISINSCOPE(PRUEBA[HORA]),COUNT(PRUEBA[ID]),
ISINSCOPE(Calendario[Nombre_dia]),COUNTROWS(FILTER(_table,[Nombre_dia] in VALUES(Calendario[Nombre_dia]))),
ISINSCOPE(PRUEBA[ENTIDAD]),COUNTROWS(FILTER(_table,[Nombre_dia] in VALUES(Calendario[Nombre_dia]))),
ISINSCOPE('Calendario'[Semana del mes]),SUMX(VALUES(Calendario[Semana del mes]),_b),
ISINSCOPE(PRUEBA[EJECUTIVO DE VENTAS]),SUMX(VALUES(PRUEBA[EJECUTIVO DE VENTAS]),_b),
ISINSCOPE(Calendario[Mes]),SUMX(VALUES(Calendario[Mes]),_b))
return _a

vtangjiemsft_0-1703152883000.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.