Trying to make a report in Tableau that would show the following sales stats:
- sales yesterday
- sales week-to-date
- sales month-to-date
- sales run-rate (30 days) - based on month-to-date calculation
The problem is that the data source is Shopware DB and it stores all historical states of an order: when it was created, when it was paid but not shipped, when it was shipped, when it was closed. I.e. duplicate orders.
The report is connected directly to Shopware DB without data prep. Thus, to remove the duplicate entries for each order state I am using a FIXED level of detail calculation to calclate the correct SUM:
{Fixed [Order Number],[identifier]:MIN([total_price])}
However, when I am trying to use either of solutions for MTD, YTD calculations that I found online based on this fixed calculated field "Correct SUM", I am getting totally strange numbers, which i am not even able to understand (they are much more then what I have, for example, in Power BI for the same data source; 17k USD instead of 238 USD, 65k USD instead of 55k USD, etc.).
I tried using the following calculated fields:
SUM IF:
SUM( IF MONTH([Order Date])=MONTH(TODAY()) THEN [Correct SUM] END
True/False calculated field used as a filter (as described here):
[Order Date] <= TODAY() AND DATETRUNC( "month", [Order Date]) = DATETRUNC("month", TODAY())
Can anyone advise what to do next?
total_price
. Does that mean your price varies or for sake of aggregation have you taken it? – AnilGoyal[identifier]
from level of detail in the first calculated field – AnilGoyaltotal_price
filed doesn't change in this DB. thanks for the suggestion regardingidentifier
, i will try without it – Джон