Custom Attribute (Select)

Define a calculation once at datasource level, then use it like any other column — across every tile and report.

⚠️ Prerequisite Calculated Fields
ℹ️ Drag-and-Drop Visuals Only Custom attributes work in drag-and-drop visuals. For query-based visuals, add the formula to your query — and to make that reusable, look into Query Expressions in PersivX.

PersivX lets you add new attributes — custom calculations — at the datasource level. They appear in the attributes list and behave exactly like columns that came from the datasource itself. Custom attributes are coloured blue so they're easy to tell apart from real datasource columns, which are green.

Custom attributes shown in blue alongside green datasource columns

Because the formula lives at datasource level, it can be reused across tiles and reports, and any change to the calculation flows through to every visual using it. That is more manageable than repeating a Calculated Field in each tile.

ℹ️ Nothing Is Written to Your Database Think of a custom attribute as adding a new column to a table — except the column is never actually added to the database. When used, its values are computed in real time, because they aren't stored anywhere. PersivX adds the attribute to the query itself, so as with Calculated Fields you can use any function or macro the datasource supports.

Let's use the same example as the Calculated Fields page — displaying monthly sales.

Step 1: Identify the Fields You Need

For every line item in an order we have the quantity ordered and the price of each unit. First calculate the line total: lineTotal = orderNumber * priceEach.

The fields available on the order details table

Step 2: Choose Where the Attribute Lives

Pick which table or object to add the new attribute to. This is purely organizational — it doesn't change behaviour, but keeping attributes in sensible places makes them much easier to find as their number grows.

lineTotal belongs under the orderDetails table. Click + New Attribute under the table name and set the attribute type to SELECT QUERY.

Creating a new attribute under a table
ℹ️ Why SELECT QUERY This type tells PersivX to use the formula as-is when fetching data.

Step 3: Write the Formula

Add the formula and give the attribute a name. A description is optional, and the formula can be edited later.

ℹ️ Formula Rules Use the recommended SQL format — each column written as <TABLE_NAME>.<COLUMN_NAME>. A formula may reference columns from different tables. And because the formula is used verbatim in the query, you can use any function or macro the datasource provides: date functions like EXTRACT(YEAR FROM …), aggregates like SUM, MAX, or GROUP_CONCAT, and conditionals like IF-ELSE or WHEN-THEN-END.

The formula we want is orderNumber * priceEach, which in the recommended format becomes:

Formula
order_details.xlsx.orderNumber * order_details.xlsx.priceEach

Here order_details.xlsx is the table name as shown in PersivX — the .xlsx appears because this example works from Excel files uploaded to PersivX.

Entering the custom attribute formula

Step 4: Use It

Click save and the attribute is immediately available to drag and drop. Add it to the visual.

Dragging the new lineTotal attribute onto a visual

The values show up — but we want a SUM over lineTotal for each month to get monthly order totals.

You could edit lineTotal into orderTotal with the formula SUM(order_details.xlsx.orderNumber * order_details.xlsx.priceEach). It's better practice to create a second attribute, so both lineTotal and orderTotal remain available in future.

Step 5: Create the orderTotal Attribute

orderTotal belongs on the orders.xlsx table. Create a new attribute there and name it orderTotal.

Creating the orderTotal custom attribute

We could write out the full expression again, but lineTotal already computes it — so the formula simplifies to:

Formula
SUM(order_details.xlsx.lineTotal)
ℹ️ Custom Attributes Follow the Same Format lineTotal is referenced as order_details.xlsx.lineTotal, where order_details.xlsx is the table the attribute was created on.

Step 6: Swap It Into the Visual

Save, then remove lineTotal from the visual and add orderTotal.

The visual now showing monthly order totals

That gives the monthly sales figure. Drop more attributes onto the visual and PersivX updates the queries automatically. As always, you can change the visual type and customize the look and feel of each column.

💡 Reuse lineTotal and orderTotal can now be added to any visual on this report, or on any other report using this datasource.