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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
wujunmin
Advocate I
Advocate I

Simple Bullet Chart by a measure

wujunmin_0-1637311067350.png

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

 

 

0 REPLIES 0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors