Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
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:
 
					
				
				
			
		
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
 
            | User | Count | 
|---|---|
| 75 | |
| 36 | |
| 31 | |
| 29 | |
| 26 |