Understanding the TREATAS Function in DAX with a Real Use Case 

In Power BI, the TREATAS function is a powerful DAX function that allows us to apply the values from one column as if they belonged to another. It helps create a virtual relationship between tables that are not physically connected, making it especially useful for advanced reporting scenarios. 

This blog explains how the TREATAS function works and demonstrates it through a practical example where a disconnected date table is used to filter sales data. 

What is TREATAS in DAX? 

Syntax: 

TREATAS(<Table>, <Column1>[, <Column2>]…) 
 

Parameters: 

  • Table – A table expression that provides the values to be treated as filters. 
  • Column – The destination column where those values should be applied. 

Unlike traditional relationships, TREATAS applies filters during query execution, allowing unrelated tables to work together without modifying the data model. 

Why Use TREATAS? 

TREATAS is useful when: 

  • Your model doesn’t have a physical relationship between two tables. 
  • You want to use disconnected slicers. 
  • You need more flexibility in applying filters. 
  • You’re building What-If scenarios or parameter tables. 
  • Creating a relationship isn’t practical or could complicate the model. 

It provides a clean and efficient way to transfer filter context between unrelated tables. 

Real Example: Monthly Sales Using a Disconnected Date Table 

Suppose we have two tables: 

Date Table 

Contains: 

  • Date 
  • Year 
  • Quarter 
  • Month 

SalesData 

Contains: 

  • Date 
  • Product 
  • Sales 

There is no relationship between these two tables. 

A slicer is created using Date Table[Date], but since the tables are disconnected, selecting dates does not filter the SalesData table automatically. 

Our objective is to make the sales visual respond to the slicer without creating a relationship. 

The DAX Formula 

Treatas = 
CALCULATE( 
    SUM(SalesData[Sales]), 
    TREATAS( 
        VALUES(‘Date Table'[Date]), 
        SalesData[Date] 
    ) 

 

How the Formula Works 

The formula works in three simple steps: 

  • VALUES(‘Date Table'[Date]) captures all dates selected in the slicer. 
  • TREATAS() applies those selected dates as filters on SalesData[Date]
  • CALCULATE() evaluates the SUM of Sales only for the filtered records. 

Although the tables remain disconnected, the measure behaves as if a relationship exists between them. 

Result in the Report 

As shown in the report: 

  • The user selects March, April, and May in the Date Table slicer. 
  • TREATAS transfers those selected dates to the SalesData table. 
  • The visual displays sales only for the selected months. 
  • All other dates are excluded from the calculation. 

This provides users with the expected filtering experience without adding a physical relationship to the model. 

Another Practical Use Case 

Consider a business where the Budget table and Sales table are maintained separately and intentionally remain disconnected. Using TREATAS, report developers can apply product, region, or department filters from one table to another, making it easy to compare Budget vs Actual values without redesigning the model. 

This makes TREATAS a valuable function for enterprise Power BI reports where flexibility and reusable models are important. 

Best Practices 

  • Use TREATAS for disconnected slicers and parameter tables. 
  • Prefer physical relationships whenever possible. 
  • Combine it with VALUES() or SELECTEDVALUE() for dynamic filtering. 
  • Test performance on large datasets, as virtual relationships can increase query execution time. 
  • Keep DAX measures simple and well-documented for easier maintenance. 

Conclusion 

TREATAS is one of the most flexible DAX functions in Power BI, enabling developers to create virtual relationships between unrelated tables. In this example, it allowed a disconnected Date Table to filter the SalesData table without creating a physical relationship. 

While physical relationships should remain the first choice whenever possible, TREATAS is an excellent alternative for scenarios requiring greater flexibility. Understanding this function helps developers build more dynamic, interactive, and scalable Power BI reports while keeping the data model clean and efficient. 

Facebook
Twitter
LinkedIn

Addend Analytics is a Microsoft Gold Partner based in Mumbai, India, and a branch office in the U.S.

Addend has successfully implemented 100+ Microsoft Power BI and Business Central projects for 100+ clients across sectors like Financial Services, Banking, Insurance, Retail, Sales, Manufacturing, Real estate, Logistics, and Healthcare in countries like the US, Europe, Switzerland, and Australia.

Get a free consultation now by emailing us or contacting us.

Facebook
Twitter
LinkedIn
Translate »