Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
@tamerj1 provided an ingenious solution to my No CALCULATE Challenge -- Round #2. However, I couldn't easily figure out how to adapt it to a situation where the measure is non-additive and the filtering I want to do is not a single value from a column.
In this case, I want to recreate this deceptively simple measure:
Distinct Orders (Non-China Benchmark) =
CALCULATE (
DISTINCTCOUNT ( Sales[OrderKey] ),
Geography[RegionCountryName] <> "China"
)
For motivation purposes, assume China is an outlier in my data that I want to ignore for benchmarking purposes.
Note that this probably isn't something I'd use on its own. It would likely be used as a denominator in another measure like this:
Distinct Order Ratio =
DIVIDE (
[Distinct Orders],
CALCULATE (
[Distinct Orders],
Geography[RegionCountryName] <> "China"
)
)
For full credit:
The primary goal is to find any solution.
The secondary goal is to find one that can be grokked by a non-expert.
Sample screenshot:
Sample PBIX file attached.
Prior participants: @SharmaAntriksh, @Greg_Deckler, @CNENFRNL, @ValtteriN
Other friends: @BA_Pete, @bcdobbs, @smpa01, @parry2k
Solved! Go to Solution.
inside a measure,
Note that measures implicitly use CALCULATE, somewhat negating your premise.
Having said that, try this version
DONCB =
VAR b = ADDCOLUMNS(ALL(Geography[RegionCountryName]),"do", [Distinct Orders])
RETURN SUMX(FILTER(b,[RegionCountryName]<>"China"),[do])
@AlexisOlson
Here is a solution using SUMMARIZECOLUMNS.
Distinct Orders (Non-China Benchmark) TJ =
COUNTROWS (
SUMMARIZECOLUMNS ( Sales[OrderKey],
FILTER (
ALL ( Geography[RegionCountryName] ),
Geography[RegionCountryName] <> "China"
),
"@Count", COUNTROWS ( Sales )
)
)
However, applying the same filter over a higher cardinality column will reveal the difference with the SUMX solution provided by @lbendlin . DISTINCTCOUNT is non-additive calculation, which means SUMX will result in wrong results.
Thanks for letting me know about the SummarizeColumns bug. We'll look into this.
inside a measure,
Note that measures implicitly use CALCULATE, somewhat negating your premise.
Having said that, try this version
DONCB =
VAR b = ADDCOLUMNS(ALL(Geography[RegionCountryName]),"do", [Distinct Orders])
RETURN SUMX(FILTER(b,[RegionCountryName]<>"China"),[do])
@lbendlin, @Dangar332 There's a visual level filter excluding a few countries, which accounts for the missing orders. It's working as intended even though it's a bit weird in this toy scenario.
HI, @AlexisOlson
Measure for Not taking Order count of China which are use in another for Taking Total.
Measure =
var a =
COUNTROWS(SUMMARIZECOLUMNS(
Sales[OrderKey],
FILTER(
VALUES(Geography[RegionCountryName]),
Geography[RegionCountryName] <> "China"
),"sf",COUNTROWS(Sales)
))
RETURN
a
Measure for Distinct Order (Non-China Benchmark)
Distinct Order (Non-China Benchmark)_Dangar=
SUMX(
ALL(
Geography[RegionCountryName]),
[Measure]
)
Retio
Distinct Order Ratio_ =
DIVIDE([Distinct Orders],[Distinct Order (Non-China Benchmark)_Dangar])
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
23 | |
21 | |
20 | |
14 | |
12 |
User | Count |
---|---|
43 | |
31 | |
24 | |
22 | |
22 |