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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
KasZaz
New Member

Calculated Column within a measure or waht?

Hello, 

 

I dont know how to solve this, maybe someone will know, maybe you?

 

In my understanging of power Bi I need e measure that makes calculation on column dynamicly calculated in thid measure. Is it possible or is there different solution to this? Look at the data:

 

Order 1Customer AProduct 1
Order 1Customer AProduct 2
Order 2Customer AProduct 1
Order 3Customer BProduct 2
Order 4Customer CProduct 1

 

Now, I need to display the number of customers that had a specific number of orders, and filter visual according to the product type. 

So at the beginig:

Customers with 1 order: 2 (B, C)

Customers with 2 orders: 1 (A)

Thats easy, I can do calculated column for that. But thats static. Now I want to filter this data according to the product:

For product 1

Clients with 1 order: 1 (C)

Clients with 2 orders: 1 (A)

And so on...

 

I have about 1500 customers, 100 products and they make about 10 000 orders in a year. 

 

Any ideas?

I tried to calculate this first column within a measure, but it seems any functions like count need to have name of an existing calcutated column and it didnt work. I feel this case is beyond my pBI skill right now 😕 Help pls 😄

2 REPLIES 2
danextian
Super User
Super User

hI @KasZaz ,

 

A calculated column is, of course, static but what are you really trying to achieve? If you want the count of orders by product by customer, you can simply create a calc column for that.

=
CALCULATE (
    COUNTROWS ( 'table' ),
    //countrows - assuming that each row in the table is equivalent to an order
    FILTER (
        'table',
        'table'[customer]
            = EARLIER ( 'table'[customer] ) & 'table'[product]
            = EARLIER ( 'table'[product] )
    )
)




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thank for replying a lot, 

 

so yeah, EARLIER function is half of my solution that I didnt know, I have to admit. But how do I count them, not counting one Customer many times?

 

So my table now is:

   By customer by product count 
Order 1Customer AProduct 1  2 
Order 1Customer AProduct 2  1 
Order 2Customer AProduct 1  2 
Order 3Customer BProduct 2  1 
Order 4Customer CProduct 1  1 

 

So for product 1 number of customers with 1 order is: 1

For product 1 number of customers with 1 orders is: 1

for product 2.... and so on

 

So basicly how to count ones and twos in this column, counting every customer only once. Filtering or slicing by product I think I can handle. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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