Forum Discussion

Dayna's avatar
Dayna
Helper V
2 years ago
Solved

Conditional formatting on a field based on field length

Hello All,   I suspect this is fairly easy, but as I'm very new to conditional formatting within PowerBI, I'm struggling a bit...    I have a table of products, and they have barcodes against the...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Dayna ,

    My idea is to create a what-if parameter, get its value and save it as a variable to be passed to the code in the conditional format.


    Use parameters to visualize variables - Power BI | Microsoft Learn
    Then create 2 measures for conditional format:

    Measure 1 = 
    VAR _len = MAX('Lengths'[Lengths])
    VAR _result = IF(LEN(MAX('Table'[Barcode 1]))=_len,"Green","Red")
    RETURN
    _result
    Measure 2 = 
    VAR _len = MAX('Lengths'[Lengths])
    VAR _result = IF(LEN(MAX('Table'[Barcode 2]))=_len,"Green","Red")
    RETURN
    _result

    When the length parameter is changed, the condition format also changes.

    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