Replacing date with words inside a listed if condition

Hello support.

On the attached, we need the “Description” field to display the following:
If the CustTransLines/@CustomerRef_WLP is empty, display the month based on the “Date” field, plus the word usage.

So on the attached template the ARFT266 Description should be “September usage”

Can this be done?

Google PIA Statement.docx (77.0 KB)
Google PIA Statement_CustAccountStatementExt.Report.ddsp (136.2 KB)

Hi @Nicky,

I’m not sure it’s a good idea to include such a complicated XPath expression in the template, since it might be hard to maintain and change later on. I think it would be better to handle this in the code. But I did play around with it, and here’s an example of the expression that should work for you.

iif(@CustomerRef_WLP = ‘’,
iif(month(@CustTrans_TransDate) = 1, concat(‘January’, ’ usage’),
iif(month(@CustTrans_TransDate) = 2, concat(‘February’, ’ usage’),
iif(month(@CustTrans_TransDate) = 3, concat(‘March’, ’ usage’),
iif(month(@CustTrans_TransDate) = 4, concat(‘April’, ’ usage’),
iif(month(@CustTrans_TransDate) = 5, concat(‘May’, ’ usage’),
iif(month(@CustTrans_TransDate) = 6, concat(‘June’, ’ usage’),
iif(month(@CustTrans_TransDate) = 7, concat(‘July’, ’ usage’),
iif(month(@CustTrans_TransDate) = 8, concat(‘August’, ’ usage’),
iif(month(@CustTrans_TransDate) = 9, concat(‘September’, ’ usage’),
iif(month(@CustTrans_TransDate) = 10, concat(‘October’, ’ usage’),
iif(month(@CustTrans_TransDate) = 11, concat(‘November’, ’ usage’),
iif(month(@CustTrans_TransDate) = 12, concat(‘December’, ’ usage’), ‘’)))))))))))),
@CustomerRef_WLP)

Here’s the final result in the document:

Be careful when copying the expression, as some symbols might change. Please review and fix them manually if needed. Give it a try and let me know if it works for you.

Hi Amir,

Thank you. This statement is specifically for a handful of customers, and changing the code is just going to mess with the statements that are already correct. I figured doing it in the template is easier.

I need one more modification, if possible. The condition only needs to apply to documents starting with ARFT. If this isn’t possible I will have to look at duplicating the report and changing the code.

Thank you for your help. :slight_smile:

Hi @Nicky,

Could we get this value from the “AccountNum” field, or where can I find it in the data schema?

HI Amir,

It’s the CustTrans_Invoice field:

image

Hi @Nicky,

In this case, I would use the following XPath expression:

iif(@CustomerRef_WLP = ‘’ and @CustTrans_Invoice ,
iif(month(@CustTrans_TransDate) = 1, concat(‘January’, ’ usage’),
iif(month(@CustTrans_TransDate) = 2, concat(‘February’, ’ usage’),
iif(month(@CustTrans_TransDate) = 3, concat(‘March’, ’ usage’),
iif(month(@CustTrans_TransDate) = 4, concat(‘April’, ’ usage’),
iif(month(@CustTrans_TransDate) = 5, concat(‘May’, ’ usage’),
iif(month(@CustTrans_TransDate) = 6, concat(‘June’, ’ usage’),
iif(month(@CustTrans_TransDate) = 7, concat(‘July’, ’ usage’),
iif(month(@CustTrans_TransDate) = 8, concat(‘August’, ’ usage’),
iif(month(@CustTrans_TransDate) = 9, concat(‘September’, ’ usage’),
iif(month(@CustTrans_TransDate) = 10, concat(‘October’, ’ usage’),
iif(month(@CustTrans_TransDate) = 11, concat(‘November’, ’ usage’),
iif(month(@CustTrans_TransDate) = 12, concat(‘December’, ’ usage’), ‘’)))))))))))),
@CustomerRef_WLP)

This XPath expression checks if @CustomerRef_WLP is empty and if @CustTrans_Invoice starts with “ARFT”. If both conditions are true, it returns the transaction month from @CustTrans_TransDate with the corresponding month name followed by “usage” (e.g., “January usage”). If these conditions are not met, it returns @CustomerRef_WLP.

In short: It outputs “Month usage” based on the transaction date if the invoice starts with “ARFT” and @CustomerRef_WLP is empty, otherwise it returns @CustomerRef_WLP.

Google PIA Statement_AmirTest.docx (77.6 KB)

This is perfect.

This expression will also help in another design, thank you so much.