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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Creating a Slicer from a Conditional Formatting Formula

Hi everyone, I originally needed this code below (coupon or deal format) to apply conditional formatting when an item was on a deal/coupon depending on the date. However, I now need to modify this formula, with the same filters, to become a slicer based on yesterday's deals/coupons. The end goal is to create a metric that I can slice by coupon, deal, prime exclusive deal, lightning deal, etc. Thanks for your help!

Coupon or Deal Format = 
VAR tempTable =
    FILTER (
        'Deals and Coupons',
        'Deals and Coupons'[Coupon Start Date] <= SELECTEDVALUE ( 'Calendar'[Date] )
        && 'Deals and Coupons'[Coupon End Date] >= 'Deals and Coupons'[Coupon End Date]
        && 'Deals and Coupons'[Deal Start Date] <= SELECTEDVALUE ( 'Calendar'[Date] )
        && 'Deals and Coupons'[Deal End Date] >= 'Deals and Coupons'[Deal End Date]
        && 'Deals and Coupons'[Prime Exclusive Discount Start Date] <= SELECTEDVALUE ( 'Calendar'[Date] )
        && 'Deals and Coupons'[Prime Exclusive Discount End Date] >= 'Deals and Coupons'[Prime Exclusive Discount End Date]
    )
VAR MINIMUMDATE =
    MINX ( tempTable, 'Deals and Coupons'[Coupon Start Date] )
VAR MAXIMUMDATE =
    MAXX ( tempTable, 'Deals and Coupons'[Coupon End Date] )
VAR MINIMUMDATE2 =
    MINX ( tempTable, 'Deals and Coupons'[Deal Start Date] )
VAR MAXIMUMDATE2 =
    MAXX ( tempTable, 'Deals and Coupons'[Deal End Date] )
VAR MINIMUMDATE3 =
    MINX ( tempTable, 'Deals and Coupons'[Prime Exclusive Discount Start Date] )
VAR MAXIMUMDATE3 =
    MAXX ( tempTable, 'Deals and Coupons'[Prime Exclusive Discount End Date] )
VAR DATE2 =
    MAXX ( tempTable, 'Deals and Coupons'[Lightning Deal Date] )
RETURN
    IF (
        AND (
            SELECTEDVALUE ( 'Calendar'[Date] ) >= MINIMUMDATE,
            SELECTEDVALUE ( 'Calendar'[Date] ) <= MAXIMUMDATE
        ),
        "#A9F099",
    IF (
        AND (
            SELECTEDVALUE ( 'Calendar'[Date] ) >= MINIMUMDATE2,
            SELECTEDVALUE ( 'Calendar'[Date] ) <= MAXIMUMDATE2
        ),
        "#97E6F8",
    IF (
        AND (
            SELECTEDVALUE ( 'Calendar'[Date] ) >= MINIMUMDATE3,
            SELECTEDVALUE ( 'Calendar'[Date] ) <= MAXIMUMDATE3
        ),
        "#E6A1CB",
    IF (
            SELECTEDVALUE ( 'Calendar'[Date] ) = DATE2,
        "#D1CEFF"
    ))))

 

1 REPLY 1
sandeephijam
Helper I
Helper I

Hi grbs,

 

Please explain more on what you want to achive with few more data, you can use the code you have posted only when you know where to plugin what

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors