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.
Solved! Go to Solution.
Hi @Damian911 ,
I am glad to help you.
@Jihwan_Kim ,Thank you very much for your help with this case!
I've come up with another solution that I'd like to share.
Based on your description, I think you can try to change the DAX code to this:
Spool =
CALCULATE(
AVERAGE('AllInvoiceDetails'[Quantity]),
FILTER(
'Product',
'Product'[ProductGroup] = "Spool"
)
)
I created the following test data as you described it.
It is recommended to use the filter function in the calculate function to filter out a separate range for calculation (from the Product table to filter out ProductGroup = "Spool" rows of data), then only ProductGroup for the "Spool" rows will be used in the previous average method. (Requires a relationship between the tables.)
Using the filter function, it is possible to individually restrict a calculation range (creating a new table), which does not affect the other dax expressions of the model.
Here's what happens when no relationship is created between tables:
The results for both are incorrect.
When a relationship is established between two tables:
The above code not only calculates the average value in the "spool" according to the filter range, but also calculates the duplicate ID (value 2) records only once.
The above measure using the filter function is correct, and correspondingly, the following expression does not change the filter range before and after the relationship is created.
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Damian911 ,
I am glad to help you.
@Jihwan_Kim ,Thank you very much for your help with this case!
I've come up with another solution that I'd like to share.
Based on your description, I think you can try to change the DAX code to this:
Spool =
CALCULATE(
AVERAGE('AllInvoiceDetails'[Quantity]),
FILTER(
'Product',
'Product'[ProductGroup] = "Spool"
)
)
I created the following test data as you described it.
It is recommended to use the filter function in the calculate function to filter out a separate range for calculation (from the Product table to filter out ProductGroup = "Spool" rows of data), then only ProductGroup for the "Spool" rows will be used in the previous average method. (Requires a relationship between the tables.)
Using the filter function, it is possible to individually restrict a calculation range (creating a new table), which does not affect the other dax expressions of the model.
Here's what happens when no relationship is created between tables:
The results for both are incorrect.
When a relationship is established between two tables:
The above code not only calculates the average value in the "spool" according to the filter range, but also calculates the duplicate ID (value 2) records only once.
The above measure using the filter function is correct, and correspondingly, the following expression does not change the filter range before and after the relationship is created.
I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Please share your sample pbix file's link.
Or, please try something like below whether it suits your requirement.
Spool =
CALCULATE (
AVERAGE ( 'AllInvoiceDetails'[Quantity] ),
'Product'[ProductGroup] IN { "Spool" }
)
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
21 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
27 | |
10 | |
10 | |
9 | |
6 |