Reputation: 115
Net Sales = CALCULATE(SUM('COMBINED'[Total]),'COMBINED'[Type]="Sales") +
CALCULATE(SUM('COMBINED'[Total]),'COMBINED'[Type]="Sales Tax Expense") +
CALCULATE(SUM('COMBINED'[Total]),'COMBINED'[Type]="Discounts")
Combined = Table Name
Total = Column with $ values
Type = Column with income / expense types.
So I have the above formula in Power BI that I'm trying to replicate as a calculated field in Tableau. How would I go about creating a field: "Net Sales" where the goal is to grab the SUM of Total where Type = 'Sales', 'Discounts', or 'Sales Tax Expense'?
Upvotes: 1
Views: 45
Reputation: 1210
Assuming that you have already brought your data source to Tableau;
Create a calculated field called Net Sales and write below formula in it. When you drag the new field to your view as SUM
(Which is the default aggregation, so normally you do not have to do anything for this), you will have the requested sum.
IF [Type] = 'Sales' or [Type] = 'Discounts' or [Type] = 'Sales Tax Expense'
THEN [Total]
ELSE 0
END
Upvotes: 1