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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to create a simple calculated column or another workaround

Hi,
 
I want to do a simple operation where I get the average amount of products per person. For this I made two measures:
 
Productos_total =
COUNT('Clientes Mac'[Cant_CA]) +
COUNT('Clientes Mac'[Cant_CC]) +
COUNT('Clientes Mac'[Cant_TC])
 
This gives me the total of products per person and then:
 
Average productos =
AVERAGEX('Clientes Mac',[Productos_total])
 
To get the average. This worked in a small dataset, however, for the 10MM rows dataset it doesnt work. I would prefer to just get the average of Productos_total but that's not possible since that is a measure.
 
My question is: Is there another way? Could someone give me a code to create a calculated column?
 
Thanks in advance,
 
IC
1 ACCEPTED SOLUTION

This is a second post of this message...not sure where the first went.  Please read this one.

 

Hi @icespedes ,

 

My pleasure!

 

In order to facilitate our conversation, would you please you the following syntax?

 

[measure name] = blah,blah,blah 

tablename [Column name] = and so forth

 

This is common usage, and lets the other person know whether they are looking at a measure or a calculated column.

 

Thank you!

 

So, I took what you presented and applied it to the original data that you gave us as follows:

"Promedio de Productos por persona =
CALCULATE(DIVIDE([Productos por persona],COUNTROWS('Data clientes lunes por 6 meses'),"No Result"),
KEEPFILTERS(VALUES('Data clientes lunes por 6 meses'[Codigo_Cliente]))
)" 
Modified to fit the original data and my modified table Clients Mac new: (Assuming this is a measure)
[Promedio de Productos por persona] =
CALCULATE(DIVIDE([Productos por Persona],COUNTROWS('Clientes Mac new'),"No Result"),
KEEPFILTERS(VALUES('Clientes Mac new'[Client]))
)

And

"Productos por persona =
COUNT('Data clientes lunes por 6 meses'[Cant_CA]) +
COUNT('Data clientes lunes por 6 meses'[Cant_CC]) +
COUNT('Data clientes lunes por 6 meses'[Cant_TC]) +
COUNT('Data clientes lunes por 6 meses'[Cant_CD]) +
COUNT('Data clientes lunes por 6 meses'[Cant_NE]) +
COUNT('Data clientes lunes por 6 meses'[Cant_PR_Vh]) +
COUNT('Data clientes lunes por 6 meses'[Cant_PR_Com]) +
COUNT('Data clientes lunes por 6 meses'[Cant_PR_Hip]) +
COUNT('Data clientes lunes por 6 meses'[Cant_PR_Tie]) +
COUNT('Data clientes lunes por 6 meses'[Cant_PR_Per]) +
COUNT('Data clientes lunes por 6 meses'[Cant_PR_LC])"
to
[Productos por Persona] = COUNT('Clientes Mac new'[Cant_CA])+ COUNT('Clientes Mac new'[Cant_CC])+COUNT('Clientes Mac new'[Cant_TC])
 
So, would you agree that these are both measures and equivalent?  If not we should discuss. 
 
So based on your latest and applied to our original data, I get:
productos por persona.PNG 
 and 
Promedio de.PNG
 
So looking at our original data, would you expect the count of products to be 16, or 21?
 
And looking at our original data, would you expect the count of unique clients to be 4?
 
I will post some more, but this may get you started.
Thank you,




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

18 REPLIES 18

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.