Hello,
Is there a solution to include the value of the quarter in the value of the year
in this sample calculation?
@Marcin Kozera Another approach would be to use level of detail (LOD) calculation to return the whole year of sales when [periods] = 'this year'
MIN(
IF DATETRUNC("quarter",[Order Date])=DATETRUNC("quarter",TODAY())
THEN {FIXED DATETRUNC("quarter",[Order Date]) : SUM([Sales])}
ELSEIF DATETRUNC("year",[Order Date])=DATETRUNC("year",TODAY())
THEN { FIXED DATETRUNC("year",[Order Date]) : SUM( [Sales])}
END
)
A couple of things I'll point out here: It wasn't necessary to use a FIXED expression to return the whole quarter of sales; However LODs aggregate differently inside of an IF THEN statement, so for simplicity I have converted all output into LODs and then wrapped the whole calculation in MIN(). If you haven't worked with LODs before, I recommend checking out How Level of Detail Expressions Work in Tableau
Also note, I added the [Product Name] filter to context per Calculations with Fixed Expression Return Unexpected Results When Filtered
Please @ me in replies otherwise I won't receive a notification. Vote for more notification options
Hope this helps :)
What do you think of the new Community Forums? Let us know!
(Be sure to tag your ideas as 'community')