Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Is measure context a thing?

I have lots of cards, each visualising a different measure and I am trying to conditional formatting for the background.

I could create the following measure for each and every card:

IF(CONTAINSSTRING([My Measure1], "test"), "#DS351C", "#00703C")

 

But rather than creating lots of measures, referencing [My Measure1], [My Measure2], [My Measure3].... is there a way to grab the measure context of the visual and have a single conditional formatting measure that checks the result of the measure in the visual and returns the colour as above?

My inital guess was: 

IF(CONTAINSSTRING(SELECTEDMEASURE(), "test"), "#DS351C", "#00703C")

 

But upon further research it doesn't appear SELECTEDMEASURE() is used for this purpose.

Hopefully my request is clear.

Thanks.

6 REPLIES 6
themistoklis
Community Champion
Community Champion

@Anonymous 

Try something like the below formula:

 

Measure Value Color =

SWITCH(TRUE(),
VALUE([Measure Value1]) <=1,"#000000",

VALUE([Measure Value2]) <=15,"#000022",

VALUE([Measure Value2]) <=26,"#000033",

BLANK()

)

 

 

Anonymous
Not applicable

actually thinking about it, this won't work as it it won't cycle through all measures, the moment it hits true it will stop and ignore the following measures thus won't format the remaining backgrounds correctly.

Mahesh0016
Super User
Super User

@Anonymous Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Anonymous
Not applicable

Hi Mahesh,

 

Unfortunately I can't share a file but to give more context...

Card 1 displays the results of Measure 1, results of Measure 1 = abc

Card 2 displays the results of Measure 2, results of Measure 2 = xyz

Card 3 displays the results of Measure 3, results of Measure 3 = mno

 

i want to conditionally format the background of these cards based on the results of the measures.

 

I could create three measure to do this:

 

Card 1 formatting: IF(CONTAINSSTRING([Measure1], "abc"), "#DS351C", "#00703C")

Card 2 formatting: IF(CONTAINSSTRING([Measure2], "abc"), "#DS351C", "#00703C")

Card 3 formatting: IF(CONTAINSSTRING([Measure3], "abc"), "#DS351C", "#00703C")

 

Is there a function that sees the measure context of the visual that would allow me to have a single measure that i don't have to populate with all measures?

 

 

Anonymous
Not applicable

Hi Mahesh,

 

Unfortunately I can't share a file but to give more context...

Card 1 displays the results of Measure 1, results of Measure 1 = abc

Card 2 displays the results of Measure 2, results of Measure 2 = xyz

Card 3 displays the results of Measure 3, results of Measure 3 = mno

 

i want to conditionally format the background of these cards based on the results of the measures.

 

I could create three measure to do this:

 

Card 1 formatting: IF(CONTAINSSTRING([Measure1], "abc"), "#DS351C", "#00703C")

Card 2 formatting: IF(CONTAINSSTRING([Measure2], "abc"), "#DS351C", "#00703C")

Card 3 formatting: IF(CONTAINSSTRING([Measure3], "abc"), "#DS351C", "#00703C")

 

Or i could do a switch statement as per @themistoklis but is there a function that sees the measure context of the visual that would allow me to have a single measure that i don't have to populate with all measures?

 

 

hello @Anonymous ,
can i know all measure calculated by one column or different column use by every measure and can share your measure writtend.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.