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.
Hi.
I have a matrix with the purpose to show what we have sold or not sold to a customer based on this measure:
My question:
Solved! Go to Solution.
[Total Quantity] = SUM( 'Salestable1'[Sales Quantity] )
[Sold/Not Sold] =
var CutofffDate = DATE( 2021, 5, 1)
var TotalQuantityBeforeIsNotPositive =
CALCULATE(
[Total Quantity] <= 0,
// 'Calendar' must be a proper date table
// in the model connected to the fact table.
'Calendar'[Date] < CutoffDate
)
var TotalQuantityAfterOrOnIsPositive =
CALCULATE(
[Total Quantity] > 0,
// 'Calendar' must be a proper date table
// in the model connected to the fact table.
'Calendar'[Date] >= CutoffDate
)
var TotalQuantityWeirdnessCondition =
TotalQuantityBeforeIsNotPositive
&&
TotalQuantityAfterOrOnIsPositive
var Result =
switch( true(),
TotalQuantityWeirdnessCondition,
"<glowing star>",
[Total Quantity] > 0,
UNICHAR(9989),
// When [Total Quantity] <= 0...
UNICHAR(10060)
)
return
Result
[Total Quantity] = SUM( 'Salestable1'[Sales Quantity] )
[Sold/Not Sold] =
var CutofffDate = DATE( 2021, 5, 1)
var TotalQuantityBeforeIsNotPositive =
CALCULATE(
[Total Quantity] <= 0,
// 'Calendar' must be a proper date table
// in the model connected to the fact table.
'Calendar'[Date] < CutoffDate
)
var TotalQuantityAfterOrOnIsPositive =
CALCULATE(
[Total Quantity] > 0,
// 'Calendar' must be a proper date table
// in the model connected to the fact table.
'Calendar'[Date] >= CutoffDate
)
var TotalQuantityWeirdnessCondition =
TotalQuantityBeforeIsNotPositive
&&
TotalQuantityAfterOrOnIsPositive
var Result =
switch( true(),
TotalQuantityWeirdnessCondition,
"<glowing star>",
[Total Quantity] > 0,
UNICHAR(9989),
// When [Total Quantity] <= 0...
UNICHAR(10060)
)
return
Result
@daxer-almighty that seems to work great!
It seems like I cant sort it by the three conditions in my matrix:
Do you have a solution for this aswell?
And: is it possible to get those three conditions in a slicer visual?
Appreciate it!
Of course, it is possible. But what do you mean by "can't sort them"? The <glowing star> is something I put in but you have to change it to the right unicode character. Then, to sort them the way you want you have to use a trick called "zero-character space" and attach 0, 1 and 2 such spaces to the beginning of each of these unicode chars. Google for an article on sorting measure values on www.sqlbi.com or find the relevant vid on YT by Alberto Ferrari where he shows how to do it.
To get these chars in a slicer you have to create a disconnected table with these chars (plus the spaces) as values. It'll be a disconnected dimension.
@Anonymous , if date is in context of the visual then try like (correct the unicode)
Switch(true() ,
SUM('Salestable1'[Sales Quantity])>0 && Max(Date[Date]) >= date(2021,05,01),UNICHAR(9989),
SUM('Salestable1'[Sales Quantity])>0 && Max(Date[Date]) < date(2021,05,01),UNICHAR(10060),
,UNICHAR(10060))
If not they you have create measure for before and after 1st may
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
9 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
11 | |
11 | |
10 | |
6 |