March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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!
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
14 | |
11 | |
8 | |
5 |
User | Count |
---|---|
26 | |
21 | |
20 | |
14 | |
10 |