The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
HI,
I am creating a calculated column called 'LOC_conditionalFormat' that assigns a value based on two other columns. Here is my current code:
Solved! Go to Solution.
Try:
LOC_conditionalFormat =
SWITCH (
TRUE (),
OR (
ISBLANK ( 'Loneliness All Data'[Locus Of Control Mean] ),
ISBLANK ( 'Loneliness All Data'[LOC Previous Year] )
), 4,
'Loneliness All Data'[Locus Of Control Mean] > 'Loneliness All Data'[LOC Previous Year], 1,
'Loneliness All Data'[Locus Of Control Mean] < 'Loneliness All Data'[LOC Previous Year], 2,
'Loneliness All Data'[Locus Of Control Mean] = 'Loneliness All Data'[LOC Previous Year], 3,
0
)
Proud to be a Super User!
Paul on Linkedin.
Try:
LOC_conditionalFormat =
SWITCH (
TRUE (),
OR (
ISBLANK ( 'Loneliness All Data'[Locus Of Control Mean] ),
ISBLANK ( 'Loneliness All Data'[LOC Previous Year] )
), 4,
'Loneliness All Data'[Locus Of Control Mean] > 'Loneliness All Data'[LOC Previous Year], 1,
'Loneliness All Data'[Locus Of Control Mean] < 'Loneliness All Data'[LOC Previous Year], 2,
'Loneliness All Data'[Locus Of Control Mean] = 'Loneliness All Data'[LOC Previous Year], 3,
0
)
Proud to be a Super User!
Paul on Linkedin.
@PaulDBrown Just wondering if you could help with one more addition to the solution you provided? How would I adjust your solution so that LOC_conditionalFormat didn't create a value for every row but only on rows where another column [Variable] contained the letters 'PC'?
Try:
LOC_conditionalFormat =
IF (
CONTAINSSTRING ( MAX( Table[Variable] ) , "PC" ),
SWITCH (
TRUE (),
OR (
ISBLANK ( 'Loneliness All Data'[Locus Of Control Mean] ),
ISBLANK ( 'Loneliness All Data'[LOC Previous Year] )
), 4,
'Loneliness All Data'[Locus Of Control Mean] > 'Loneliness All Data'[LOC Previous Year], 1,
'Loneliness All Data'[Locus Of Control Mean] < 'Loneliness All Data'[LOC Previous Year], 2,
'Loneliness All Data'[Locus Of Control Mean] = 'Loneliness All Data'[LOC Previous Year], 3,
0
)
)
Proud to be a Super User!
Paul on Linkedin.
Hi @PaulDBrown , when I use your code it only creates empty cells. Not sure why! I will maybe repost this as a new question!
What is the actual syntax for the [Variable] you mentioned? Is it a measure or column? If it's a column, what is the syntax?
the MAX(Table[Variable]) was an assumption on my part, and is probably why you are getting blanks
Proud to be a Super User!
Paul on Linkedin.
Hi Paul,
I was able to get this code to do what I wanted:
User | Count |
---|---|
65 | |
62 | |
60 | |
53 | |
28 |
User | Count |
---|---|
181 | |
82 | |
67 | |
48 | |
44 |