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
Anonymous
Not applicable

Count number of same values and multiply with value from another table

Hi all,

 

I'm new to Power BI and still struggling a bit.

I have two tables, one shows me the orders and the other one shows me the prices for the different products. Now I want to get the revenue per product (per year) by counting how many times a product was orderes from the list that shows me the orders and then multiplying this with the respective price. 

I tried to create a chart that shows me the different products and as value I've tried to create a Quick Measure multiplying the amount of sold products with the price, but this is not possible.

Can anyone help me here?

 

Cheers!

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @Anonymous 

First, make sure that there is a one to many relationship between the two tables based on.

Then create a calculate column in the order table to fill in the price of the product table

_price = RELATED ( Prices[Price] )

Sample:

v-angzheng-msft_0-1619501987053.jpeg

To create a measure to calculate the Revenue:

Revenue =
CALCULATE (
    COUNTROWS (
        FILTER ( 'Orders', 'Orders'[Product] <= MAX ( 'Orders'[Product] ) )
    )
        * SELECTEDVALUE ( 'Orders'[_price] )
)

Result:

v-angzheng-msft_1-1619501987055.jpeg

Please refer to the attachment below for details

 

 

Is this the result you want? Hope this is useful to you

Please feel free to let me know If you have further questions

 

Best Regards,
Community Support Team _ Zeon Zheng
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

14 REPLIES 14
v-angzheng-msft
Community Support
Community Support

Hi, @Anonymous 

First, make sure that there is a one to many relationship between the two tables based on.

Then create a calculate column in the order table to fill in the price of the product table

_price = RELATED ( Prices[Price] )

Sample:

v-angzheng-msft_0-1619501987053.jpeg

To create a measure to calculate the Revenue:

Revenue =
CALCULATE (
    COUNTROWS (
        FILTER ( 'Orders', 'Orders'[Product] <= MAX ( 'Orders'[Product] ) )
    )
        * SELECTEDVALUE ( 'Orders'[_price] )
)

Result:

v-angzheng-msft_1-1619501987055.jpeg

Please refer to the attachment below for details

 

 

Is this the result you want? Hope this is useful to you

Please feel free to let me know If you have further questions

 

Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below picture and the sample pbix file's link whether it is what you are looking for.

I created a simple sample by myself, and I tried to include the information you want and measures you need.

All measures are in the sample pbix file.

 

Picture1.png

 

https://www.dropbox.com/s/bhbgwtmv6j8yddj/Picture1.png?dl=0 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

Hi Jihwan Kim,

 

thank you, that's exactly what I am looking for! I only see the dropbox link to the picture, where can I find the pbix file?

Hi, @Anonymous 

Sorry, here is the correct link

 

https://www.dropbox.com/s/pkj9pi2n9vpvkvx/friedl.pbix?dl=0

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

So if I understand it right I first need to sort the sales after days? 

Hi, @Anonymous 

Thank you for your feedback.

Sorry, I did not understand your question well.

In my sample, dates are just the date each sale happened.

If your data has a different structure, then the data model needs to be created differently and measures have to be created differently. 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

Hi Jihwan Kim,

 

here's some sample data to show you the structure of my data model. 

https://www.dropbox.com/s/aubykp93ktr8guk/Sample_Data.pbix?dl=0

Hi, @Anonymous 

Please check the link down below.

Dim-Calendar table and Dim-Contry table are created.

At the moment, the relationships between DimCalendar Table and Order Table are all inactive relationships.

If you want to activate one of the relationships, you can use userelationship function in the new dax measures.

All measures are in the sample pbix file.

 

https://www.dropbox.com/s/axauiibjwlji136/Sample_Data.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

Hi Jihwan Kim,

 

thank you for the file. I think I wasn't clear in my expressions. 

With Order no I mean the unique number that is created for every order. So I want to calculate the different orders by counting the different order numbers, I think you understood Order no as amount of orders. 

Hi, @Anonymous 

Sorry for my misunderstanding.

I confused the Order number with how many numbers of orders.

I am familiar with seeing something like Order ID No., and I was not careful enough and confused.

I think the link down below seems like matching your expected outcome that is presented before by you.

You can check the changed measures in the sample pbix file.

 

https://www.dropbox.com/s/axauiibjwlji136/Sample_Data.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Anonymous
Not applicable

Sure, sorry! 

This is my table with the orders:

Friedl123_0-1619364707444.png

This is my table with the prices:

Friedl123_1-1619364747498.png

Now I want to create a chart that shows me the revenue by multiplying the amount of sold product with the price for the product, so that it looks like that in the end:

Friedl123_2-1619364822829.png

 

@Anonymous 

Please see the attachment below





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

Proud to be a Super User!




Anonymous
Not applicable

Thank you!!

ryan_mayu
Super User
Super User

@Anonymous 

could you please provide the sample data and the expected output?





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

Proud to be a Super User!




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!

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.