string - SSRS choosing dynamic Columns -


For my report, I have to choose which columns are dynamically accessing the database < pre> FCST_Sales_2014_Q4_with_SF FCST_Sales_2015_Q1_with_SF FCST_Sales_2015_Q2_with_SF FCST_Sales_2015_Q3_with_SF

I need: to be more precice:

column in the database, thus named for the current year and quarter Report to choose, so I am using now () which I need to composite with expression For example:

  = year (now ())   

and

  = switch (month ( Now ()) = 1, 1, month (now ()) = 2, 1, month (now ()) = 3, 1, month (now ()) = 4, 2, month (now ()) = 5 , 2, month (now ()) = 6, 2, month (now ()) = 7, 3, month (now ()) = 8, 3, month (now ()) = 9, 3, month (now ()) = 10, 4, month (now ()) = 11, 4, month (now ()) = 12, 4)   

results 2014 And 4 what exactly i want If I am using the following:

  = ( "field! Fsissisass_s +" + Sisarar (Year (Now ()) + "_kyu" + CSR (switch (Month (Now () ) = 1, 1, month (now ()) = 2,1, month (now ()) = 3,1, month (now ()) = 4, 2, month (now ()) = 5,2, Month (now ()) = 6,2, month (now ()) = 7,3, month (now ()) = 8,3, month (now ()) = 9,3, month (now ()) = 10, 4, month (now ()) = 11,4, month (now ()) = 12,4)) + "_with_SF")   

I need string exactly ( FCST_Sales_2014_Q4_with_SF ) But the problem is that I I can not use the .value operation if I add the sum () and .value to the expression then I get the error message , Then there is no member of the .value string. Expression I used:

  = add (("! Fields FCST_Sales_" + CSTR (year (Now ()) + '_Q "+ CSTR (switch (month (now ()) = 1,1, month (now ()) = 2,1, month (now ()) = 3,1, month ( Now ()) = 4,2, month (now ()) = 5,2, month (now ()) = 6,2, month (now ()) = 7,3, month (now ()) = 8 , 3, month (now () ) = 9,3, month (now ()) = 10, 4, month (now ()) = 11,4, month (now ()) = 12,4) + "_with_SF"). Value)   

Is there a solution for this problem?

You can not create such an area - you are actually creating a string what you want to do The field name is created to look it up in the field collection, so instead:

  field! FieldName.Value   

looks like this:

  field ("field name"). Value   

So you can use your very large expression:

  = yoga (field ("FCSSASS_s +" + CST (year (now ( ) (+) + "_Q" + CSR (Switch (month (now ()) = 1, 1, month (now ()) = 2, 1, month (now ()) = 3, 1, month (now ( ) = 4,2, month (now ()) = 5, 2, month (now ()) = 6, 2, month (now ()) = 7, 3, month (now ()) = 8, 3 , Month (now ()) = 9, 3, month (now ()) = 10, 4, month (now ()) = 11, 4, month (now ()) = 12, 4)) + "_with_SF" ). Value)   

You can also simplify that expression. You must do this for:

  (month (today) + 2) \ 3   

then your expression below

  = add (fields ("FCST_Sales_" + CSTR (year (today)) + '_Q "+ CSTR ((month (today) + 2) \ 3) +' _with_SF"). Value)  alternative method the dynamically field using SQL to create name   

another potentially simple way by using a dynamic SQL string. coherent field names for example, if your SQL looked like this : From MyTable

  Defense Select FCST_Sales_2014_Q4_with_SF   

You can change that leads to a SQL statement is a string expression. Right-click the dataset, select the dataset property and click on the Expression Editor fx button next to the query. Now we can create SQL statements from a string, such as

  = "SELECT FCST_Sales_" + Sisarar (Year (Today)) + "_Q" + CSR ((Month (today) + 2) \ 3) + "_with_SF AS FCST_Sales" and "From MyTable"   

Now you are dynamically making the field name in SQL query and it is FCST_Sales In the dataset so that you can easily use the known field value in your report, which makes your calculations very easy:

  = Field! FCST_Sales.Value   

and

  = SUM (field! FCST_Sales.Value)    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -