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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Libbyb23
Resolver I
Resolver I

How would I conditional format this in PBI for a table?

Hi, 

I am working on a report that changes the background color of a date column based on how many days a deal has been in a stage. My team would like to set these conditional rules based on which stage it is in (see below). However, I am not sure how to do the write the rules to change based on which stage. For example, my report is working based on deal stage 6 rules but for all stages.

Libbyb23_0-1727114590424.png

Libbyb23_1-1727114652711.png

 

I am not sure were to add the deal stage parameter to create it as my sales directors intended.

Any help is appreciated. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Libbyb23 ,

 

If you can get the deal stage in the current context, try this:

 

Measure = 
VAR __cur_stage = SELECTEDVALUE('Table'[Deal Stage])
VAR __days = SUM('Table'[Days Opened])
VAR __result = 
    SWITCH(
        TRUE(),
    __cur_stage IN {5,6},
        SWITCH( 
            TRUE(),
            __days < 0 && __days >= -60, "Green",
            __days < -60 && __days >= -90, "Yellow",
            __days < -90 && __days >= -1000, "Red"
        ),
    __cur_stage = 4,
        SWITCH( 
            TRUE(),
            __days < 0 && __days >= -30, "Green",
            __days < -30 && __days >= -60, "Yellow",
            __days < -60 && __days >= -1000, "Red"
        ),
    __cur_stage IN {2,3},
        SWITCH( 
            TRUE(),
            __days < 0 && __days >= -15, "Green",
            __days < -15 && __days >= -30, "Yellow",
            __days < -30 && __days >= -1000, "Red"
        )
    )
RETURN
    __result

 

vcgaomsft_0-1727154761371.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum 

View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

@Libbyb23 it has to be a measure not a column.



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.

Anonymous
Not applicable

Hi @Libbyb23 ,

 

If you can get the deal stage in the current context, try this:

 

Measure = 
VAR __cur_stage = SELECTEDVALUE('Table'[Deal Stage])
VAR __days = SUM('Table'[Days Opened])
VAR __result = 
    SWITCH(
        TRUE(),
    __cur_stage IN {5,6},
        SWITCH( 
            TRUE(),
            __days < 0 && __days >= -60, "Green",
            __days < -60 && __days >= -90, "Yellow",
            __days < -90 && __days >= -1000, "Red"
        ),
    __cur_stage = 4,
        SWITCH( 
            TRUE(),
            __days < 0 && __days >= -30, "Green",
            __days < -30 && __days >= -60, "Yellow",
            __days < -60 && __days >= -1000, "Red"
        ),
    __cur_stage IN {2,3},
        SWITCH( 
            TRUE(),
            __days < 0 && __days >= -15, "Green",
            __days < -15 && __days >= -30, "Yellow",
            __days < -30 && __days >= -1000, "Red"
        )
    )
RETURN
    __result

 

vcgaomsft_0-1727154761371.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum 

Trying this now! Thanks!!

parry2k
Super User
Super User

@Libbyb23 or check out this video on my channel - it addresses similar question: How to make conditional formatting scalable and easy to manage in Power BI (youtube.com)



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.

parry2k
Super User
Super User

@Libbyb23 then it should be super easy. It will be easier if you share pbix file using one drive/google drive with the expected output. Remove any sensitive information before sharing.



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.

parry2k
Super User
Super User

@Libbyb23 does the transaction table have deal stage column?



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.

Yes it does!!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors