Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Apply conditional formatting on Y-axis:IF(SALES>=TARGET, "DARKCYAN","TOMATO")
Measure:
BulletChart =
VAR StoreCount =
DISTINCTCOUNT ( 'Table'[StoreID] )
VAR MaxSales =
MAXX ( VALUES ( 'Table'[StoreID]), [Sales])
VAR MAXTarget=
MAXX ( VALUES ( 'Table'[StoreID]), [Target])
VAR MAXValue=MAX(MaxSales,MAXTarget)
VAR BarTable =
ADDCOLUMNS (
SUMMARIZE (
'Table',
'Table'[StoreID],
"Index", RANKX ( ALLSELECTED ( 'Table' ), [Sales],,, DENSE )
),
"Rect",
"<rect rx='3' x='20' y='" & ( [Index] - 1 ) * 20 & "' width='" & 100*[Sales]/ MAXValue & "' height='10' fill='DarkCyan' />",
"Text",
"<text x='18' y='"
& ( [Index] - 1 ) * 20
+ 7 & "' text-anchor='End' font-size='6' fill='"&IF([Sales]/[Target]>=1,"DarkCyan","Tomato")&" '>" & [StoreID]& "</text>",
"Label",
"<text x='"&21+100*[Sales]/MAXValue&"' y='"
& ( [Index] - 1 ) * 20
+ 7 & "' text-anchor='left' font-size='6' >"
& ROUND ( [Sales], 0 ) & "</text>",
"Rect_Target",
"<rect x='"& 20+100*[Target]/ MAXValue&"' y='" & ( [Index] - 1 ) * 20 & "' width='0.5' height='10' fill='Tomato' />"
)
VAR Bar =
CONCATENATEX ( BarTable, [Rect] & [Text]&[Label]&[Rect_Target] )
VAR SVG = "<svg xmlns='http://www.w3.org/2000/svg' viewbox='0 0 141 "&20*StoreCount &"' >" & Bar & "</svg>"
RETURN
SVG