Conditional paragraphs?

I’m working on the idea of a dynamic report for our clients. The idea is to track which versions of, say, Ruby they’re currently running, and to make recommendations based on that.

To this end I’ve created the following document: Quarterly Product Report

It contains a table with data on the different versions of Ruby available, along with a table which is used to show which version was in use at any one point in time (the idea being that once every 3 months, we generate a new report by adding a new row to the table, with the versions as they exists at that point in time).

What I’m then trying to do is build a mad-libs report, based on the data set in the most recent row of this second table. I’ve had some amount of success with this, as you can see from the paragraph under the Ruby heading.

It’s the paragraph under this which I’m having some trouble with. I want a conditional which check if there’s an end of life date for the selection version, and either shows a static “you’re OK, for now” message if the date is missing, or a dynamic “end of life is going to happen in x number of days”.

The following gets me part way there, but I’m not sure how I can add some dynamic values alongside the static text in the ifFalse block.

If(
  [ruby version].[End of Life].IsBlank(),
  "There isn't currently an end of life for this version, so you're probably good where you are.",
  "How do I make this dynamic?"
)

Furthermore, are there any ways in which I can make entire sections of the document show or hide based on a conditional? So rather than having to fit all the relevant content within a function call like above, but instead be able to create complex differences, and have them show/hide based on certain values?

Thank you.

Hi Daniel,

Welcome to Coda! Hope that you will find the product useful.

One quick suggestion on the static texts, rather than make then static, add them to a table, with the different pieces of the message (dynamic and static) each in their own cell. Then use Concatenate() to add the various pieces together,

Regards
Piet

1 Like

That’s fantastic, thank you. Concatenate() is the bit I was missing, and I like the idea of storing the content in another table.

I’d still be interested in conditionals for entire sections of the document, but I think this will do me for now.

Thank you again.

I’ve ended up with the following, which looks a little cumbersome, but should be more flexible. Are there any improvements to this you can recommend?

If(
  [ruby version].[End of Life].IsBlank(),
  Copy.Lookup(Copy.Label, "No end of life").Text,
  Concatenate(
    Copy.Lookup(Copy.Label, "End of life intro").Text,
    [ruby version].[Until end of life],
    Copy.Lookup(Copy.Label, "End of life outtro").Text
  )
)
2 Likes

Hey @Daniel_Hollands ,

You can do it in so many different ways! (As is always the case with Coda)
Check out the document below, I personally like the third way the best because it gets rid of the whole intro/outro referencing
.

3 Likes

Thank you, @Scott_Collier-Weir - that’s very helpful.

I’ve ended up with something that is a bit of a hybrid of all approaches.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.