- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Referencing to Measure or rather working with variables?
Hello Community,
Usually I create a lot of measures and even use nested measures as well. But now I am wondering if thats a best practice approach. Should I use variables rather than nesting or referencing to other measures?
An example for calculating a simple ratio.
Approach 1 with nestes measures:
- Measure 1 = SUM( value 1 )
- Measure 2 = SUM( value 2 )
- Measure 3 = DIVIDE( Measure 2, Measure 1 )
Approach 2 with variables:
- Measure 1:
var 1 = SUM( value 1 )
var 2 = SUM( value 2 )
RETURN
DIVIDE( 2, 1 )
What do you think?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As usual, IT DEPENDS. If you have defined meaningful business measures, then you should reuse them as much as possible because code duplication is the first step to hell. You should catch measure values into variables most of the time and give them good names. Remembering at that that a measure's value stored in a variable will never change. This is helpful when used correctly. Also, using variables is very beneficial when debugging code. The rule I go by is: If your expression is short, you don't need to catch everyching into variables because the short code (with well named measures) speaks for itself. If your expression is complex, use variables with good names.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @raymondpocher ,
For me Approach 2 works better. There are few reasons for using variables rather than multiple measures:
- Using variables make my DAX calculation simpler and easy to understand.
- If I have everything in a single DAX expression, it is easy to maintain, specially in the cases where the DAX is not working as expected then debugging is easier. You need to check one expression for debugging rather than checking multiple measures used to create this calculation.
- Based on my previous experience with writing DAX, I have seen that use of variables improves performance as well. You can check this for example on the two visuals displaying calculation output using Approach 1 and Approach 2.
This is my view, but I am sure others will have more to add to this.
Thanks,
Pragati

Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Power BI Monthly Update - February 2025
Check out the February 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
09-17-2024 10:55 AM | |||
10-03-2024 01:26 PM | |||
07-30-2024 11:37 AM | |||
12-05-2024 06:10 AM | |||
10-13-2023 09:00 AM |
User | Count |
---|---|
24 | |
12 | |
11 | |
10 | |
9 |
User | Count |
---|---|
18 | |
14 | |
13 | |
12 | |
10 |