Yearly sales report with Pivot

I have a SQL query to get a sales report with this year and last year.

In this Query i declared the following:
DECLARE @cols VARCHAR (30)
DECLARE @cols2 VARCHAR (30)

DECLARE @query NVARCHAR (MAX)
set @cols = convert(varchar,year(getdate()))  + ',' + convert(varchar,year(getdate()) -1)
set @cols2 = '[' + convert(varchar,year(getdate()) ) + '],[' + convert(varchar,year(getdate()) -1) + ']'

This query works fine. But when I use it within FastReport how to use it to get this year and last year dynamic in the report.

I have it working, but now I use:
  m_AantalDitJaar.Memo.Text:='[DBXQ_Factuuregels."2018"]';
  m_AantalVorigJaar.Memo.Text:='[DBXQ_Factuuregels."2017"]';

And I can't get it working like this:
  m_AantalDitJaar.Memo.Text:='[DBXQ_Factuuregels.<YearOf(DATE)]';
  m_AantalVorigJaar.Memo.Text:='[DBXQ_Factuuregels.YearOf(DATE)-1]';

Does any one have a clue?

Comments

  • edited March 2018
    I did found it:
    m_AantalDitJaar.Memo.Text:='[DBXQ_Factuuregels."' + IntToSTR(YEAROF(<Date>)) + '"]';
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.