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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jvbs
Helper I
Helper I

Conditional Formatting using Total as Params

Hello everyone,

 

I need to implement a conditional formatting on this table where the FPD % cell is compared to it's total, like in the example below, where the 17,9% must be compared to 10,1% and, if it's bigger, paint it red.

 

power_bi3.PNG

 

Is it possible? I tried with a measure to use in comparison but no success 😞

1 ACCEPTED SOLUTION

Hi @jvbs ,

 

In your scenario, ALL is the key to achieve the goal.I have created a sample for your reference. 

% FPD30 = 
CALCULATE ( SUM ( 'Table'[value] ), FILTER ( 'Table', 'Table'[val] = "y" ) )
    / CALCULATE ( SUM ( 'Table'[value] ) )
Measure = 
VAR a =
    CALCULATE ( SUM ( 'Table'[value] ), FILTER ( 'Table', 'Table'[val] = "y" ) )
        / CALCULATE ( SUM ( 'Table'[value] ) )
VAR b =
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER ( ALL ( 'Table' ), 'Table'[val] = "y" )
    )
        / CALCULATE ( SUM ( 'Table'[value] ), ALL ( 'Table' ) )
RETURN
    IF ( a >= b, "green", "red" )

Capture.PNG

 

For more details, please check the pbix as attached. If it doesn't meet your requirement,  Kindly share your sample data and excepted result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

5 REPLIES 5
parry2k
Super User
Super User

@jvbs yes it is doable, what is the current expression for %



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

You mean my FPD field expression?

Create a measure like

Color sales = if(AVERAGE(Sales[Sales Amount])<170,"green","red")

 

Then go to Visualization pane -> Format -> Conditional format -> Background color(on) -> Advance Control -> Choose field Value and choose this measure

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Thanks for your answer @amitchandak , but in my case, the number "170" should be dynamic, the 10,1% is not fixed. I tried to put a measure in it's place but it doesn't work at all 😞

Hi @jvbs ,

 

In your scenario, ALL is the key to achieve the goal.I have created a sample for your reference. 

% FPD30 = 
CALCULATE ( SUM ( 'Table'[value] ), FILTER ( 'Table', 'Table'[val] = "y" ) )
    / CALCULATE ( SUM ( 'Table'[value] ) )
Measure = 
VAR a =
    CALCULATE ( SUM ( 'Table'[value] ), FILTER ( 'Table', 'Table'[val] = "y" ) )
        / CALCULATE ( SUM ( 'Table'[value] ) )
VAR b =
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER ( ALL ( 'Table' ), 'Table'[val] = "y" )
    )
        / CALCULATE ( SUM ( 'Table'[value] ), ALL ( 'Table' ) )
RETURN
    IF ( a >= b, "green", "red" )

Capture.PNG

 

For more details, please check the pbix as attached. If it doesn't meet your requirement,  Kindly share your sample data and excepted result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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