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
Hello all,
I hope you can help, I think it is just a matter of understanding the filter in CALCULATE.
I am currently using a calculate function and I can´t explain the result myself. For example in the following measure I want to calculate the average of all process times for product type "B".
Process Time B =
CALCULATE(
AVERAGE(
TableX[Process Time]
),
TableX[Product] = "B"
)
In general and without other slicers the results seems right (let´s say 6,5h). But once I add a slicer, e.g. for product type, and select other product types than "B" the value changes.
My understanding though was that CALCULATE overrules any other filters. So I expected the card-visual for "Process Time B" to show 6,5h regardless of the settings in the product-type-slicer, because it is "Product B"-specific. Nevertheless, the result for Process Time B changes.
How can that be? I would appreciate any help.
Kind regards
Nick
Solved! Go to Solution.
I found the problem. The value was influenced by the date-slicer, that was referencing the date column of the fact table. Since I created a date dimension table and changed the reference of the slicer, it works with only a CALCULATE function!
I tried. Using All(TableX) as another Filter in CALCULATE unfortunately leads to no filtering at all.
What is the column you are using as the filter in the slicer?
put ALL on that column
It doesn´t solve it.
But maybe back to my original question: Why does the slicer (Product Type) affect the result of my CALCULATE function, where I already filtered product type to be "B"? For example when I am slicing product type "A" only.
Side note: When I am slicing product type "A" and "B" the value is correct again (like slicing product type "B" only).
I understand that other filters have influence on the measure. But since product type is already filtered in the measure, I expected the measure to overrule the product type slicer at least.
In the example: I expected the correct value. But instead it is a value not far from the correct one and I can´t explain that.
As far as I understand, if the filter is applied to the same column that is also used in the slicer, the slicer's selection should be overwritten by the calculate filter.
Maybe try also this:
Process Time B =
CALCULATE(
AVERAGE(
TableX[Process Time]
),
Filter(All(TableX),
TableX[Product] = "B",)
)
Again, this leads to no filtering at all.
Process Time B =
CALCULATE(
AVERAGE(
TableX[Process Time]
),
Filter(All(TableX[Product]),
TableX[Product] = "B",)
)
if not paste the pbix
I oversaw something. It doesn´t work after all.
Sounds really strange to me. Maybe paste the pbix I don't know
I found the problem. The value was influenced by the date-slicer, that was referencing the date column of the fact table. Since I created a date dimension table and changed the reference of the slicer, it works with only a CALCULATE function!
That works!
Is there any possibility to do that without a FILTER-function to save performance? That was also my initial objective.
Already tried this?
Process Time B =
CALCULATE(
AVERAGE(
TableX[Process Time]
),
All(TableX[Product]),
TableX[Product] = "B"
)
Do you really have performance issue using filter or it's just speculation?
As i know every filter put in the calculate functions it gets converted behind the scenes in a filter so
First of all, thank you for your time and help!
I tried this already. With that it shows the same values like the original code:
Process Time B =
CALCULATE(
AVERAGE(
TableX[Process Time]
),
TableX[Product] = "B"
)
Do you have a DIM tabel or you are just filtering from the fact column table?
Tablex is the fact or the dim?
Paste the screen of the model.
Anyway you probably need to put an all somewhere, maybe on the dim table
The data model is really simple. All data for this described case is in the fact table (TableX). I am not using data from dimension tables.
just try this then
Process Time B =
CALCULATE(
AVERAGE(
TableX[Process Time]
),
TableX[Product] = "B",
All(TableX)
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |