Forum Discussion
TREATAS in DAX
I was going through DAX, there i got a function "TREATAS". This made me little confused that what this function is really about and what is the workflow, uses and how to use it. Can anyone explain "TREATAS" in DAX with an example.
I tried to understand the concept of TREATAS and expecting the explanation in detail with example.
Hi Lohith_2404 - The TREATAS function in DAX is used to apply filters from one table to another unrelated table. It allows you to propagate filters across tables without an explicit relationship in the data model.
syntax: TREATAS(<column(s)>, <table>)
When to Use TREATAS?
✔ No direct relationships exist between tables.
✔ Need to apply filters dynamically from one table to another.
✔ Helps in virtual relationships when you don’t want to clutter the model with unnecessary joins.
✔ Works well in Disconnected Tables (Budgeting, Forecasting, What-If Analysis).TREATAS function - DAX | Microsoft Learn
you can find more details from above learn document. Hope this helps.
- Anonymous1 year ago
Hi Lohith_2404
Thank you very much rajendraongole1 for your prompt reply.
Please allow me to share a post here (reply 13/17):
Solved: Re: New Dax to calculate sum by changing join - Page 2 - Microsoft Fabric Community
And here's a simple example:
“Dim”
“Fact”
Note that there is no relationship between the two tables.
This code calculates the sum of the Amount column in the Fact table, but it filters the data in the Fact table based on the Color column in the Dim table.
TREATAS Test = CALCULATE( SUM('Fact'[Amount]), TREATAS( VALUES('Dim'[Color]), 'Fact'[Color] ) )Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- rajendraongole1Super User
Hi Lohith_2404 - The TREATAS function in DAX is used to apply filters from one table to another unrelated table. It allows you to propagate filters across tables without an explicit relationship in the data model.
syntax: TREATAS(<column(s)>, <table>)
When to Use TREATAS?
✔ No direct relationships exist between tables.
✔ Need to apply filters dynamically from one table to another.
✔ Helps in virtual relationships when you don’t want to clutter the model with unnecessary joins.
✔ Works well in Disconnected Tables (Budgeting, Forecasting, What-If Analysis).TREATAS function - DAX | Microsoft Learn
you can find more details from above learn document. Hope this helps.
- AnonymousNot applicable
Hi Lohith_2404
Thank you very much rajendraongole1 for your prompt reply.
Please allow me to share a post here (reply 13/17):
Solved: Re: New Dax to calculate sum by changing join - Page 2 - Microsoft Fabric Community
And here's a simple example:
“Dim”
“Fact”
Note that there is no relationship between the two tables.
This code calculates the sum of the Amount column in the Fact table, but it filters the data in the Fact table based on the Color column in the Dim table.
TREATAS Test = CALCULATE( SUM('Fact'[Amount]), TREATAS( VALUES('Dim'[Color]), 'Fact'[Color] ) )Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.