cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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

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

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

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

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors