Skip to main content

Posts

Showing posts with the label YTD

MTD, Previous MTD, Last MTD, YTD and Previous YTD (LY YTD) Calculation in Tableau

MTD, Previous MTD, Last MTD, YTD and Previous YTD (LY YTD) calculation in Tableau MTD : Select  Analysis  >  Create Calculated Field  Name the field MTD Sales, enter the following calculation, then click OK: [Order Date] <= TODAY() AND DATETRUNC( "month", [Order Date]) = DATETRUNC("month", TODAY() ) Drag MTD onto the filter shelf and select "True" [Trip Date] <= TODAY() AND DATETRUNC( "month", [Trip Date]) = DATETRUNC("month", TODAY() ) OR if [Run Date] <= TODAY() AND DATETRUNC( "month", [Date Field]) = DATETRUNC("month", TODAY() )then ([Total Sales]) else 0 end Last MTD : IF DATEDIFF('month',[Run Date], TODAY()) = 1 AND DAY([ Date Field ]) <= DAY(TODAY())THEN ([Total Sales])END On the 1st of month MTD is usually shown blank, to handle this: Create " This MTD or Last MTD"  filter as shown below then create this logic:  ( DATEPART( 'day', TO...