Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
aef
Regular Visitor

Better Performance with TREATAS

Hi,

 

I am working on a report that used a managed model, which I am unable to edit. I have a business requirement to report on something that has no direct relationship on the model and I've been informed by the model owner that this cannot be changed.

 

In order to achieve this, I have created a number of measures using TREATAS, but the performance across the report is suffering. I understand that by the nature of using TREATAS, the performance will be slower, but I wondered if there are any tips to improve the below to make this run faster. For info, this is currently taking 15-20 seconds to run.

 

Store_Measure =
CALCULATE(
DISTINCTCOUNT(FactStore[StoreID]),
NOT (FactStore[StoreClosureReason] IN {"xx", "yy"},
TREATAS(
VALUES(ProxyCountry[CityID]), FactStore[CityID])
)

 

The requirement is to report by Country, but the country is not available on FactStore. 

 

Country Name is available on DimCountry and this is linked to ProxyCountry the model as below:


DimCountryTable ProxyCountryTable
CountryID 1:* CountryID

 

ProxyCountry has a CityID column, which I have used to filter FactStore using TREATAS.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @aef ,

Based on your problems, here are my answers.

Using TREATAS introduces additional filtering, which may impact performance. To mitigate this, consider reducing the base level in the model. Please create a relationship directly between DimCountry and FactStore.

 

Instead of repeating complex expressions, use variables to store intermediate results. This improves readability and performance. For example, before applying TREATAS, you can create a variable to hold the filtered CityID from ProxyCountry.

 

If the TREATAS logic remains constant across multiple metrics, consider creating a calculated column to precalculate the necessary values. Then, use this column in the metric values.

 

You can also consider the DirectQuery mode, which avoids loading all the data into memory, which can significantly improve the performance of large datasets.

 

Finally, you can also read this document for the further study: Propagating filters using TREATAS in DAX - SQLBI

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @aef ,

Based on your problems, here are my answers.

Using TREATAS introduces additional filtering, which may impact performance. To mitigate this, consider reducing the base level in the model. Please create a relationship directly between DimCountry and FactStore.

 

Instead of repeating complex expressions, use variables to store intermediate results. This improves readability and performance. For example, before applying TREATAS, you can create a variable to hold the filtered CityID from ProxyCountry.

 

If the TREATAS logic remains constant across multiple metrics, consider creating a calculated column to precalculate the necessary values. Then, use this column in the metric values.

 

You can also consider the DirectQuery mode, which avoids loading all the data into memory, which can significantly improve the performance of large datasets.

 

Finally, you can also read this document for the further study: Propagating filters using TREATAS in DAX - SQLBI

 

 

 

Best Regards

Yilong Zhou

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.