Home > Software engineering >  How to add a total value column for a Waterfall Chart in Plotly
How to add a total value column for a Waterfall Chart in Plotly

Time:11-03

I'm trying to add a "total value" column in my waterfall chart but I'm not why I can't do it as this data is in my table. See my actual table:

DealID    Customer     deal value (USD)      Measure
Q1        SIEMENS AG     $1.200.000         Relative
Q2        SIEMENS AG     $800.000           Relative
Q3        SIEMENS AG     $2.100.000         Relative
Q4        SIEMENS AG     $450.000           Relative
Q5        SIEMENS AG     $1.000.000         Relative
Q6        SIEMENS AG     $300.000           Relative
TOTAL     SIEMENS AG     $5.850.000          Total 

This is the code used for create the waterfall chart:

import pandas as pd
import numpy as np
import plotly
import plotly.graph_objs as go

df=pd.read_excel('C:/Users/Usuario/Desktop/python/HP/waterfall.xlsx')

#store values in different variables

x=df['DealID']
y=df['deal value (USD)']
measure = df['Measure']
text=df['deal value (USD)']

fig = go.Figure(go.Waterfall(
    measure=measure,
    x=x,
    y=y,
    text=text

))

fig.show()

The output is the following:

Waterfall Output

As you can see, the total column goes up as it's a regular "relative" measure but what I was expecting is the sum of all Q's in a ending column called "Total".

Any advice about how to fix this issue?

Thanks in advance

CodePudding user response:

Looking at the enter image description here

  • Related