Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello!
I am new to Power BI and I have been struggling with letting go from the Excel mentality... I have a Table 1 that looks something like this:
SHIPMENT NUMBER | PRODUCT | COUNTRY CODE |
1 | Orange | 1234 |
6 | Orange | 1567 |
1 | Apple | 1234 |
7 | Grapes | 1234 |
8 | Apple | 8907 |
And it is related to another table (Table 2) by the COUNTRY CODE, but in this table there is only a row for each code, for example:
COUNTRY CODE |
1234 |
8907 |
1567 |
9876 |
So they have a Many to One relationship
I need to create a column in Table 2 (the ONE side of the relationship) that has the COUNT OF DISTINCT Shipments for each of the country codes, but WITH THE CONDITION of only counting the shipments that have Oranges:
COUNTRY CODE | ORANGE SHIPMENTS |
1234 | 5 |
1567 | 7 |
I can't only filter the visuals because I need the total value for each country so I can then validate the number of shipments by an If statement on another column of "If it is higher than 10, then 0.2, if not 0"... and then use the value for more calculations.
I have tried the calculate function in the Table 2 column, but it did not seem to work, it returned no value at all:
Orange Shipments= CALCULATE(
DISTINCTCOUNT('Table 1'[Shipment Number]),
'Table 1'[Product]= "Orange")
Please, how can I summarize the count of shipments with oranges by country? This has been making me crazy.
Thank you!
Solved! Go to Solution.
Hi,
Please try the below. It is for creating a new column.
Orange shipments count CC =
COUNTROWS (
SUMMARIZE (
FILTER ( RELATEDTABLE ( 'Table1' ), 'Table1'[PRODUCT] = "Orange" ),
'Table1'[SHIPMENT NUMBER]
)
)
Hi @Bia ,
Please check this formula:
Column =
CALCULATE (
DISTINCTCOUNT ( 'Table 1'[SHIPMENT NUMBER] ),
FILTER (
'Table 1',
'Table 1'[COUNTRY CODE] = 'Table 2'[COUNTRY CODE]
&& 'Table 1'[PRODUCT] = "Orange"
)
)
Best Regards,
Jay
Hi @Bia ,
Please check this formula:
Column =
CALCULATE (
DISTINCTCOUNT ( 'Table 1'[SHIPMENT NUMBER] ),
FILTER (
'Table 1',
'Table 1'[COUNTRY CODE] = 'Table 2'[COUNTRY CODE]
&& 'Table 1'[PRODUCT] = "Orange"
)
)
Best Regards,
Jay
Hi,
Please try the below. It is for creating a new column.
Orange shipments count CC =
COUNTROWS (
SUMMARIZE (
FILTER ( RELATEDTABLE ( 'Table1' ), 'Table1'[PRODUCT] = "Orange" ),
'Table1'[SHIPMENT NUMBER]
)
)
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
7 | |
7 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |