cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Regular Visitor

## Multiplying distinct count with related table

Hi,

I am new to PowerBI and have been trying to solve the below. However after searching various forums without luck I thought to ask if someone could help with the below.

We have a table (main_table) with "unique names", grouped by "project", "site" and "site category".

 UniqueNames Project Site SiteCategory Name 1 Project X A 10 Name 2 Project X A 11 Name 3 Project X A 10 Name 4 Project Y B 13 Name 5 Project Y B 13

By using a table and count the unique values of "Site Category" per Project I managed to produce the below output.

 Project Site Nbr. Unique Site Category Project X A 2 Project Y B 1

In a different table (cost) there is a value and a cost associated with each site.

 Site CostValue Price A 2 100 B 1 150

The goal is to produce a table/graph multiplying the unique site categories per project with the related cost table based on site, CostValue and Price ("Nbr. Unique Site Category" x "CostValue" x "Price").

E.g. Project X =  2 x 2 x 100, Project Y = 1 x 1 x 150

 Project Cost Project X 400 Project Y 150

A relationship has been setup between the two tables with "Site" as the linked column.

By using a measure with DISTINCTCOUNT('main_table'[SiteCategory]) I have managed to get the number of unique SiteCategory but multiplying this with the cost table does not work since it does not do this per site.

Any pointers in the right direction?

1 ACCEPTED SOLUTION
Regular Visitor

I tried that but it did not work as the top row should give value 200.

However we solved it by adding a calculated column to the main table with the cost value  and price added per row. The muliplication still did not work at first, due to one data being aggregated and the other were not. However using MAX did the trick and the data is presented correctly.

Thanks!

4 REPLIES 4
Super User

@MikeSwe , You need something like

Sumx(Summarize(main_table, main_table[Project], main_table[Site], "_1", DISTINCTCOUNT('main_table'[SiteCategory]), "_2", related(cost[CostValue]) , "_3", related(cost[Price]) ), [_1], [_2], [_3])

Regular Visitor

Hi @amitchandak ,

When trying to apply this I get an error message stating that there are too many arguments for Sumx and that two arguments is the maximum.

Community Support

Hi @MikeSwe ,

If you have created the following relationship, then I think you can try the measure.

``Measure = [Nbr. Unique Site Category] * SUM(cost[Price]) * SUM(cost[CostValue])``

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Regular Visitor

I tried that but it did not work as the top row should give value 200.

However we solved it by adding a calculated column to the main table with the cost value  and price added per row. The muliplication still did not work at first, due to one data being aggregated and the other were not. However using MAX did the trick and the data is presented correctly.

Thanks!

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors