Forum Discussion

pakdilip's avatar
pakdilip
New Member
5 months ago
Solved

Difference in Sales between two staff from the same dataset

I have a table with a structure similar to this:

StaffProductYearSales
AP12000350
AP12001267
AP22000304
AP22001250
BP12000245
BP12001263
BP22000320
BP22001210
CP12000280
CP12001235
CP22000354
CP22001311

 

I want to create a visualisation to compare the difference in sales by product over time for two selected staff. The staff will be selected via two separate filters, for example: I will select Staff A in Filter #1 and Staff B in Filter #2. 

 

The outcome I'm seeking for will be a stacked bar chart with the values being the difference in sales quantity (i.e. Sales of Staff selected in Filter #1 minus sales of Staff selected in Filter #2). The legend will be the Product and x-axis being the Year.

 

Your guidance is much appreciated. 

5 Replies

    • pakdilip's avatar
      pakdilip
      New Member

      This is exactly what I was looking for. Thank you!

  • Yes, this should be possible.

     

    A common way to handle this is to create two separate disconnected tables for Staff selection, so each slicer controls a different staff member independently.

     

    Then create measures like:

     

    - Sales for Staff selected in slicer 1

    - Sales for Staff selected in slicer 2

    - Difference = Staff 1 Sales - Staff 2 Sales

     

    You can then use that difference measure in a stacked bar/column chart, with Year on the axis and Product on the legend.

     

    The key point is that the two staff slicers should come from separate disconnected tables, otherwise both slicers will affect the same staff field and the comparison will not work correctly.