4 Replies Latest reply on Dec 21, 2015 1:38 AM by Sai Manikanta N

# Create a Year To Date Parameter Control

Hi

I have a requirement as follows

Here If user select YTD = 'No' then result would be equal to the Month selected. If  YTD='Yes' then needs to display the results from Year to Date. All the transactions are in Day level and summary displayed as total (Month or YTD value). How do I handle this scanario

Thanks

• ###### 1. Re: Create a Year To Date Parameter Control

It's pretty simple to do, do you have some sample data ?

• ###### 2. Re: Create a Year To Date Parameter Control

Hi Chris

To get the month I applied below calculated filed ([Month] is parameter)

DATENAME('month',date([Period]+ "-01")) = [Month]

Thanks

• ###### 3. Re: Create a Year To Date Parameter Control

Tableau BI: How to to show Current Year YTD, Previous 2 Years YTD in the Report.

The above link shows hot to create YTD calculation.

Again, I am sharing how to crea YTD, MTD then how to get Dynamically ano one of that.

1) Create a calculated field as below,

Name: YTD Sales

Syntax:

if year([Order Date]) = year( today())

and

[Order Date]) < = today() then [Sales] end

2) Create a calculated field as below,

Name: MTD Sales

Syntax:

if

year([Order Date]) = year( today())

and

month([Order Date]) = month( today())

and

[Order Date]) < = today() then [Sales] end

3) Right click on measures window white pane, click on Create Parameter.

4) Select "String" as data type, then select the "list" then enter the Values as below

YTD Sales Figures

MTD Sales Figures

5) Then create a calculated field as below.

Name: Select KPI

Syntax:

if [Parameter 1] = "YTD Sales Figures" then [YTD Sales]

elseif  [MTD Sales]

end

6) Now you can use the [Select KPI] in the report.

7) Drag all required Dimension as well as S[elect KPI].

8) Right click on Parameter , click on "Show Parameter Control"

Best Regards

Kumar

• ###### 4. Re: Create a Year To Date Parameter Control

Hi Shanaka Gunaratna,

Here Is my Solution:

1. Create 2 fields for YTD and MTD

2. Create another calculated field with

CASE [Parameter].[YTD]

when 'Yes' then [YTD]

when 'No' then [MTD] END

3. Please Newly calculated filed with Parameter control