Forum Discussion
Conditional formatting on a field based on field length
- Anonymous2 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 _resultMeasure 2 = VAR _len = MAX('Lengths'[Lengths]) VAR _result = IF(LEN(MAX('Table'[Barcode 2]))=_len,"Green","Red") RETURN _resultWhen the length parameter is changed, the condition format also changes.
Best Regards,
Gao
Community Support TeamIf 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
Hello! I created two measures - one for length of barcode1 and one for length of barcode2:
From here you can select what type you want (I chose background color). Fill in the pop-up that appears:
Basically - if the length of barcode 1 is not 13, I want it to be red. Repeat for Barcode2, but do it so it is anything other than 14, like below:
Viola! You have your coloring: