Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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
User | Count |
---|---|
42 | |
28 | |
23 | |
18 | |
15 |
User | Count |
---|---|
54 | |
35 | |
18 | |
17 | |
15 |