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
Markzolotoy
Impactful Individual
Impactful Individual

100% Clustered Stacked Column Chart with data labels

So far I see that this is still in "submit idea" stage, for years.

Does anyone know an unexpensive visual that would do 100% Clustered Stacked Column Chart with data labels?

 

Thanks

15 REPLIES 15
Markzolotoy
Impactful Individual
Impactful Individual

@lbendlin The data might be like this:

 

Markzolotoy_0-1677463557353.png

Ignore system_index and Total columns. System_name is my categories and AlertCount and Okcount are the values.

 

what should the result look like? different from this?

 

lbendlin_0-1677531190935.png

 

@lbendlin Data labels as actual numbers.

This should get you started. The placement of the text needs to be tuned.

lbendlin_0-1677798235921.png

 

@lbendlin I get this when I open the file:

 

Markzolotoy_0-1677801655923.png

 

no idea what that means.

 

Table:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckktyMmvTE1R0lEyNjQBkkaWFoZKsTrRSsGpRWWpRcVAIUsgNoCLZSanggRBao1NwaKORckZmWWpQAFDiMpYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [System = _t, Alerts = _t, OK = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"System"}, "Attribute", "Value"),
    #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Value", type number}})
in
    #"Changed Type"

Vega Lite:

{
  "data": {"name": "dataset"},
  "encoding": {
    "x": {
      "field": "System",
      "type": "nominal"
    },
    "y": {
      "field": "Sum of Value",
      "type": "quantitative",
      "stack":"normalize"
    },
    "yOffset": {"field": "Attribute"},
    "color": {"field": "Attribute"},
    "opacity": {
      "condition": {
        "test": {
          "field": "__selected__",
          "equal": "off"
        },
        "value": 0.3
      },
      "value": 1
    }
  },
  "layer": [
    {
      "mark": {
        "type": "bar",
        "tooltip": true
      }
    },
    {
      "mark": {
        "type": "text",
        "color": "black",
        "dx": -15,
        "dy": -15
      },
      "encoding": {
        "detail": {
          "type": "nominal",
          "field": "Attribute"
        },
        "text": {
          "type": "quantitative",
          "aggregate": "sum",
          "field": "Sum of Value",
          "format": ".0f"
        }
      }
    }
  ]
}

 

@lbendlin I was able to open the file. I see this Deneb control for the first time, please explain where this Vega code is stored and how do I get real data into it?

click the ellipsis, then "Edit".  Put the fields you want into the values well and then adjust the Vega Lite code as needed. 

 

It's a bit of a learning curve (and I'm still at the bottom of the hill) but worth spending time with.

@lbendlin So, you manually created a table, right? Also, what would you recommend to read in order to hook up real data?

The visual doesn't care where the data comes from. Specify the fields you need from your appropriate source. If the fields have different names you'll have to adjust the Vega Lite code accordingly.

@lbendlin Fine, but I dont even see how data is going into Vega code.

The very first line

"data": {"name": "dataset"},

"dataset"  is the collection of columns and measures you put into the Values well of the Deneb visual.  Like a dataframe in Python or R visuals, but without the deduplication.

@lbendlin I see. So, once I add a field from a table that tables becomes "dataset", right? Interesting, the table itself is not called "dataset". Also, in the code there is no reference to either word "data" or word "dataset". However, I am getting the idea of hooking up data.

a field from a table that tables becomes "dataset", right?

Close but no.  Columns and measures from the current filter context become the "dataset"  when you put them in the values well.  These columns can come from different tables.

lbendlin
Super User
Super User

I think they are hesitant because it exceeds the physiological dimension limit (3.5 if I recall correctly). Might be worth trying this with Deneb. Do you have some sample data and how should the result look like?

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.