Find Total and Gap Between Two Bars

DenebData.xlsx (11.6 KB)

Deneb Clustered and Stacked Chart.pbix (1.5 MB)

Hello,

I have been trying to create a graph that compares two sets of data (One being in October and one being in November, shown below referred to as SUBMISSION). Each set has sales of ProductA, ProductB, ProductC and I am trying to compare them and visualize the total on the top as well as show a percentage of difference by year on top of each two-bars if possible as shown in the second chart. So far I have the first example and I would like to add the total and the difference if possible. I am copying my code below for reference. Thank you!

Sample data:

Year PRODUCT SUBMISSION VALUE
2023 ProductB Oct-23 2234
2023 ProductB Nov-23 2343
2023 ProductA Oct-23 10460
2023 ProductA Nov-23 10682
2023 ProductC Oct-23 1201
2023 ProductC Nov-23 1142
2024 ProductB Oct-23 3419
2024 ProductB Nov-23 2827
2024 ProductA Oct-23 12719
2024 ProductA Nov-23 12826
2024 ProductC Oct-23 1615
2024 ProductC Nov-23 1560
2025 ProductB Oct-23 2794
2025 ProductB Nov-23 2918
2025 ProductA Oct-23 12256
2025 ProductA Nov-23 12900
2025 ProductC Oct-23 1457
2025 ProductC Nov-23 1547
2026 ProductB Oct-23 2967
2026 ProductB Nov-23 2851
2026 ProductA Oct-23 12421
2026 ProductA Nov-23 12929
2026 ProductC Oct-23 1396
2026 ProductC Nov-23 1518

Current Look:

Expected Outcome:
Expected outcome is like the below for each of the years, I just put an example of year 2023.

Hi @AndrewRizk.

Only had a few minutes to pursue your 2 issues, and have a quick fix for the first: to add the stack total, add another text mark with an aggregate transform to reduce the dataset appropriately.

I’ll look at the cluster gap tomorrow.
Greg
eDNA Forum - Deneb Stack Total and Cluster Gap - V1.pbix (1.5 MB)

1 Like

That does it!! Thanks a lot Greg.
Meanwhile, do you know if it is possible in Deneb to do something similar to the above however one bar would represent Oct-23 Submission for example showing the total the 2 stacked blocks as above of Product A, Product B, and Product C as an increase (Waterfall-like).

Hi @AndrewRizk.

I finally had a few minutes to look at your second issue. Here’s what I came up with:

A little restructuring of the transforms and layers was required, but the full solution is essentially:

  • continue with your layer in your spec block as per your original (with the existing “bar” and “text” marks)
  • add a new block to the layer with:
    • transform block with:
      • aggregate/sum for total stack value
      • window/lag for previous total stack value
      • calculate for variance
      • calculate for variance percent
    • layer block with:
      • “text” mark for stack total value
      • “text” mark for stack total variance value (positive=green, negative=red)

As for the leader lines to the stack total variance value, you’ll need a series of “rule” marks, and it would likely be a bit of an effort and would depend on your data. You can refer to the existing “Line Chart with Min-Max Variance” post in thee Deneb Showcase for further details.

Hope it helps.
Greg
eDNA Forum - Deneb Stack Total and Cluster Gap - V2.pbix (1.5 MB)

3 Likes

Hi @AndrewRizk.

Your “meanwhile” issue is an entirely new question. If the answer given in this thread solves you original issue, please mark the thread as solved and create a new thread for the new question with supporting uploads (you have the expected outcome image already, but provide as well the dataset and PBIX file).

Greg

Hi @Greg,

Thanks a lot! Learned a lot through this exercise as I am very new to deneb. I will open another if needed if I dont manage. Thank you

@Greg Hi Greg,

Just a small follow up on the same pbix here. Why do you think the opacity feature is not working? I have set it up in the transform as well in the encoding. I did make it work before but I am not sure where I went wrong after. Thank you!

Hi @AndrewRizk. No idea. I tried several forms, but couldn’t get the opacity to work either. I expect it has something to do with the facet/spec, but have no insight. Greg

1 Like

Thanks @Greg!!