Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I have a matrix table, with multiple rows and values. I wanted to count number of products but the measure I wrote is not summing in the table nor in card visual. Rows are coming from 6 different tables.
Some of the products repeat within the country and customer, but I want to count visible number of products.
Also I tried to calculate the average of the Days past request date but it gives me very high number, so I suppose it takes data from the whole table and I wanted to have it only for the data from the table.
I would appreciate any help.
Solved! Go to Solution.
@Maieev
In this case we need to force additivity
Count products =
SUMX (
SUMMARIZE (
'Sales Order Details',
'Sales Structure'[Country],
'Customer Sold To'[Customer Sold To],
'Sales Order Details'[Order Number]
),
COUNTROWS ( CALCULATETABLE ( VALUES ( 'Sales Order Details'[ItemDWHKey] ) ) )
)
@Maieev
Please try
Count products =
SUMX (
SUMMARIZE (
'Sales Order Details',
'Sales Structure'[Country],
'Customer Sold To'[Customer Sold To],
'Sales Order Details'[Order Number]
),
COUNTROWS (
CALCULATETABLE (
VALUES ( 'Product'[Product ID Description] ),
CROSSFILTER ( 'sales Order Details'[ItemDWHKey], 'Product'[ItemDWHKey], BOTH )
)
)
)
Hi @Maieev
Would you please indicate from which table each column in the matrix rows is coming from? Please present the relationshipd of these tables.
Sure,
Rows:
1. 'Sales Structure'[Country]
2. 'Customer Sold To'[Customer Sold To]
3. 'Sales Order Details'[Order Number]
4. 'Time - Order Entry'[Order Entry Date]
5. 'Time - Requested By'[Requested By Date]
6. 'Time -Requested By'[Days past request date] it's calculated column = DATEDIFF('Time - Requested By'[Requested By Date],TODAY(),DAY)
7. 'Product'[Product ID Description]
Values:
From 'Metrics' table, two measures:
- Request Quantity
- Request Value
and
- Count products = COUNTAX(Metrics,[Request Quantity])
It's a very big relationship model, this is a part of it, all of those are linked to Sales Order Details.
Hi @Maieev
let's try something simple like
Count products =
COUNTROWS ( VALUES ( 'Sales Order Details'[Order Number] ) )
It's counting the number of orders correctly but not the number of products:
Ok
please try
Count products =
COUNTROWS ( VALUES ( 'sales Order Details'[Product ID Description] ) )
Product ID Description field comes from a different table 'Product'[Product ID Description] and when I try to:
I meant to say
Count products =
COUNTROWS ( VALUES ( 'sales Order Details'[Product ID] ) )
I guess the Product ID exists in the Sales Order Details table.
Using 'Product'[Product ID Description] won't work unless you CROSSFILTER the relationship with Sales Order Details table to BOTH like
Count products =
COUNTROWS (
CALCULATETABLE (
VALUES ( 'Product'[Product ID Description] ),
CROSSFILTER ( 'sales Order Details'[Product ID], 'Product'[Product ID], BOTH )
)
)
Oh, getting closer.
@Maieev
In this case we need to force additivity
Count products =
SUMX (
SUMMARIZE (
'Sales Order Details',
'Sales Structure'[Country],
'Customer Sold To'[Customer Sold To],
'Sales Order Details'[Order Number]
),
COUNTROWS ( CALCULATETABLE ( VALUES ( 'Sales Order Details'[ItemDWHKey] ) ) )
)
'Product'[ItemDWHKey] 1
to
'Sales Order Details'[ItemDWHKey] many
@Maieev
Please try
Count products =
SUMX (
SUMMARIZE (
'Sales Order Details',
'Sales Structure'[Country],
'Customer Sold To'[Customer Sold To],
'Sales Order Details'[Order Number]
),
COUNTROWS (
CALCULATETABLE (
VALUES ( 'Product'[Product ID Description] ),
CROSSFILTER ( 'sales Order Details'[ItemDWHKey], 'Product'[ItemDWHKey], BOTH )
)
)
)
Yes, exactly this is it. Thanks again!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
9 | |
7 | |
7 | |
6 |
User | Count |
---|---|
21 | |
11 | |
10 | |
9 | |
8 |