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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
babaci
Regular Visitor

Deneb: Fold bar, text marks don't line up correct at top af bars.

LocExecutedEstimatedProforma
A1.193 0
A3.894 0
A1.255 0
A3.044 0
A3.310 0
A342 0
A1.366 0
A805 0
A277 0
A873 0
B1.0515370
B24030
B4424440
B8989010
B8888790
B19430
B1.16411640
B9298660
B1.66116630
B1.2635250
C298 0
C304 0
C1.203 0
C703 0
C2.166 0
C416 0
C289 0
C1.466 0
C555 0
C699 0

 

Hi,

Cannot seem to get the text mark on the right position, the need to be on the correct bar.

Any ideas on how I can get this solved...struggled but couldn't get it right.

 

Thanks.

 

babaci_0-1678739438474.png

 

 

 

{
  "data": {"name": "dataset"},
  "transform": [
    {
      "fold": [
        "Executed",
        "Estimated",
        "Proforma"
      ],
      "as": ["MoveType", "TotalMoves"]
    }
  ],
  "layer": [
    {
      "mark": {
        "type": "bar",
        "tooltip": true
      },
      "encoding": {
        "y": {
          "field": "TotalMoves",
          "type": "quantitative",
          "axis": {"title": null}
        },
        "x": {
          "field": "Loc",
          "type": "nominal",
          "sort": "descending",
          "axis": {"title": null}
        },
        "color": {
          "field": "MoveType",
          "type": "nominal",
          "title": null,
          "sort": "ascending",
          "scale": {
            "range": [
              "#666685",
              "#E3A611",
              "#DE6A73"
            ]
          }
        },
        "xOffset": {"field": "MoveType", "sort": "descending"}
      }
    },
    {
      "name": "Custom labels",
      "mark": {
        "type": "text",
        "color": "black",
        "angle": 0,
        "baseline": "top",
        "dy": -12
      },
      "encoding": {
        "text": {
          "field": "TotalMoves",
          "formatType": "pbiFormat",
          "format": "#0,,.00M"
        },
        "y": {
          "field": "TotalMoves",
          "aggregate": "sum"
        }
      }
    }
  ]
}

 

 

 

1 ACCEPTED SOLUTION

Hey @babaci, let me know if this will work. 

giammariam_0-1678753112476.png

Notes

  • once you bring this into deneb the pbiFormat for the labels should work
  • you'll want to adjust the width and height values

If this is enough to get you going, consider kudoing this reply and choosing it as the answer. If you need additional tweaks just let me know!

 

gist can be found here

spec:

 

 

{
  "width": 700,
  "height": 400,
  "data": {
    "name": "dataset"
  },
  "transform": [
    {
      "fold": ["Executed", "Estimated", "Proforma"],
      "as": ["MoveType", "TotalMoves"]
    }
  ],
  "layer": [
    {
      "encoding": {
        "y": {
          "field": "TotalMoves",
          "type": "quantitative",
          "aggregate": "sum",
          "axis": {"title": null}
        },
        "x": {
          "field": "Loc",
          "type": "nominal",
          "sort": "ascending",
          "scale": {"padding": 0.2},
          "axis": {"title": null, "labelAngle": 0}
        },
        "xOffset": {
          "field": "MoveType",
          "sort": "descending",
          "scale": {"paddingInner": 0.1}
        }
      },
      "layer": [
        {
          "name": "bars",
          "mark": {"type": "bar", "tooltip": true},
          "encoding": {
            "color": {
              "field": "MoveType",
              "type": "nominal",
              "title": null,
              "sort": "ascending",
              "scale": {"range": ["#666685", "#E3A611", "#DE6A73"]},
              "legend": {
                "orient": "none",
                "direction": "horizontal",
                "legendX": {"expr": "width/2-125"},
                "legendY": {"expr": "height+25"}
              }
            }
          }
        },
        {
          "name": "Custom labels",
          "mark": {
            "type": "text",
            "color": "black",
            "angle": 0,
            "baseline": "top",
            "dy": -12
          },
          "encoding": {
            "text": {
              "field": "TotalMoves",
              "type": "quantitative",
              "aggregate": "sum",
              "formatType": "pbiFormat",
              "format": "#0,,.00M"
            }
          }
        }
      ]
    }
  ]
}

 

 

 



Madison Giammaria
Proud to be a Super User 😄
LinkedIn

Do you frequently use Deneb to provide insights to your stakeholders? Have you considered sponsoring this free and open source custom visual? More info here!

View solution in original post

4 REPLIES 4
giammariam
Super User
Super User

Hey @babaci, could you provide the column names that you have in your dataset and a few dummy rows (here's how)?

 

happy to help with this



Madison Giammaria
Proud to be a Super User 😄
LinkedIn

Do you frequently use Deneb to provide insights to your stakeholders? Have you considered sponsoring this free and open source custom visual? More info here!

Hi @giammariam , thanks for your response. I have updated the post and added a table. Let me know if you need more info.

Hey @babaci, let me know if this will work. 

giammariam_0-1678753112476.png

Notes

  • once you bring this into deneb the pbiFormat for the labels should work
  • you'll want to adjust the width and height values

If this is enough to get you going, consider kudoing this reply and choosing it as the answer. If you need additional tweaks just let me know!

 

gist can be found here

spec:

 

 

{
  "width": 700,
  "height": 400,
  "data": {
    "name": "dataset"
  },
  "transform": [
    {
      "fold": ["Executed", "Estimated", "Proforma"],
      "as": ["MoveType", "TotalMoves"]
    }
  ],
  "layer": [
    {
      "encoding": {
        "y": {
          "field": "TotalMoves",
          "type": "quantitative",
          "aggregate": "sum",
          "axis": {"title": null}
        },
        "x": {
          "field": "Loc",
          "type": "nominal",
          "sort": "ascending",
          "scale": {"padding": 0.2},
          "axis": {"title": null, "labelAngle": 0}
        },
        "xOffset": {
          "field": "MoveType",
          "sort": "descending",
          "scale": {"paddingInner": 0.1}
        }
      },
      "layer": [
        {
          "name": "bars",
          "mark": {"type": "bar", "tooltip": true},
          "encoding": {
            "color": {
              "field": "MoveType",
              "type": "nominal",
              "title": null,
              "sort": "ascending",
              "scale": {"range": ["#666685", "#E3A611", "#DE6A73"]},
              "legend": {
                "orient": "none",
                "direction": "horizontal",
                "legendX": {"expr": "width/2-125"},
                "legendY": {"expr": "height+25"}
              }
            }
          }
        },
        {
          "name": "Custom labels",
          "mark": {
            "type": "text",
            "color": "black",
            "angle": 0,
            "baseline": "top",
            "dy": -12
          },
          "encoding": {
            "text": {
              "field": "TotalMoves",
              "type": "quantitative",
              "aggregate": "sum",
              "formatType": "pbiFormat",
              "format": "#0,,.00M"
            }
          }
        }
      ]
    }
  ]
}

 

 

 



Madison Giammaria
Proud to be a Super User 😄
LinkedIn

Do you frequently use Deneb to provide insights to your stakeholders? Have you considered sponsoring this free and open source custom visual? More info here!

@giammariam , thank you very much!! Works perfect.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors