Skip to content

Commit 753ff1a

Browse files
authored
Create Conditional-Colors-Dax-CheatSheet.md
1 parent b69dee7 commit 753ff1a

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## Static Measure to Test Syntax
2+
3+
To use one, choose conditional formatting:
4+
5+
- format style: field alpha
6+
- applies to: values only
7+
- which field: your measure
8+
9+
Here's a bunch of options. Type `ctrl+/` to quickly comment the lines on and off to compare them.
10+
11+
```ts
12+
[ Color Test ] =
13+
// note: alpha uses the range [ 0.0, 1.0 ] to mean 0% to 100% visible
14+
return
15+
"#ff00ff1f" // magenta, 50%
16+
// "#ff00ff" // magenta
17+
// "rgba( 255, 0, 255, 0.4 )"
18+
// "rgb(255, 0, 255 )"
19+
// "salmon"
20+
// "hsla( 219, 68%, 20%, 0.5 )"
21+
// "hsl( 219, 68%, 20% )"
22+
```
23+
24+
```ts
25+
[ Conditional Alpha ] =
26+
// alpha is in the range [0.0, 1.0]
27+
var curDecimal = SELECTEDVALUE( Nums[Frac], 0 )
28+
return
29+
"hsla(219, 68%, 20%," & curDecimal & ")"
30+
```
31+
```ts
32+
[ Conditional Rgb ] =
33+
// values are in the range [0, 255]
34+
var curR = SELECTEDVALUE( Nums[Decimal], 255 )
35+
var curG = SELECTEDVALUE( Nums[Decimal], 255 )
36+
var curB = SELECTEDVALUE( Nums[Decimal], 255 )
37+
return "rgb(" & curR
38+
& ", " & curG
39+
& ", " & curB
40+
& ")"
41+
```
42+
43+
## Docs describing the syntax
44+
45+
- [using `HSL`](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl)
46+
- [using `RGB`](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb)
47+
- [using `LCH`](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch) ( Not currently enabled, maybe in the future? )

0 commit comments

Comments
 (0)