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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Salle
Advocate I
Advocate I

Deneb Vega-lite: AND/OR logic

Hello everyone,

I have a control chart (see below) which I want to set a conditional color "red" if the Diameter is above or below required limits, "Diameter LSL" or "Diameter USL". If within limits "darkblue"-

I struggle to find the correct syntax in Deneb to add AND/OR statements to the condition test.
if ((Diameter > Diameter USL) OR (Diameter < Diameter LSL))...

How can I modify the code below (or is it an better way to achieve the results I want?) to also set the mark below Diameter LSL to "red"?

 },
          "encoding": {
            "color": {
	            "condition": {
	              "test":  "datum['Diameter'] > datum['Diameter USL']", "value": "red"
                     },
	              "value": "darkblue"
	    },
...

 

Capture.JPG

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @Salle,

You can use JavaScript logical operators in expressions, so something like the following will work:

"test":  "datum['Diameter'] > datum['Diameter USL'] || datum['Diameter'] < datum['Diameter LSL']"
  • And: &&
  • Or: ||
  • Not equal: !=

If you're using the predicate approach (using more structured objects rather than expressions), you can use 'predicate composition' to combine these using arrays - there's an example at the bottom of the doc page here.

Hopefully this will help get you moving. Good luck!

Regards,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

2 REPLIES 2
Salle
Advocate I
Advocate I

@dm-p , I did try using your suggestion with | | before but got error message. I guess it was related to wrong placing of " " because now it works perfectly. Thanks again!

 

By the way, great job with Deneb! I am just scratching the surface since a couple of days and really like what I seen so far! 

 

dm-p
Super User
Super User

Hi @Salle,

You can use JavaScript logical operators in expressions, so something like the following will work:

"test":  "datum['Diameter'] > datum['Diameter USL'] || datum['Diameter'] < datum['Diameter LSL']"
  • And: &&
  • Or: ||
  • Not equal: !=

If you're using the predicate approach (using more structured objects rather than expressions), you can use 'predicate composition' to combine these using arrays - there's an example at the bottom of the doc page here.

Hopefully this will help get you moving. Good luck!

Regards,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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