Power BI Measures vs Calculated Columns

Power BI Measures vs Calculated Columns

Power BI Measures and Calculated Columns can seem confusing at first glance, but on breaking down their differences, it becomes easier to understand how they work and how to effectively utilize each of them.



Power BI Measure vs Calculated Columns Summary Table
Power BI Measure vs Calculated Columns Summary Table

Row Context

This article assumes you are already familiar with Row Context. If you’re not, don’t worry?—?I’ve got you covered:

  • Calculated Columns have a pre-built in invisible Row Context.
  • Measures do not have a pre-built in Row Context and should be introduced if necessary, using functions like:
  • SUMX()
  • MAXX()
  • MINX()


Storage


Type

  • Calculated columns occupy a significant amount of storage because the data is stored directly in the data model.
  • Measures in contrast require minimal storage since only the function is saved, and the data is calculated on the fly when the measure is added to a visualization.


Filter Context

This article assumes you are already familiar with Filter Context. If you’re not, don’t worry?—?I’ve got you covered:

  • Calculated Columns are not affected by the filter context of a visual; their calculations are static. The values are merely grouped into different buckets based on the filter context, but this does not change the values in your table or cause the calculated column to be recalculated.
  • Measures, on the other hand, are directly affected by filter context. Any change in the filter context of the visualization will cause the measure to be recalculated.


So, when should I use?each of them?

As a general rule you should always try to use a measure unless, you need the data to physically exist in the Power BI Table.


Common Mistakes:

  • Using Measures Formula in Calculated Columns
  • Using Calculated Columns Formula in Measures

Explanation through Story telling:

Data through story telling
Timmy

Timmys marble business was flourishing, he wanted to calculate the profits gained from each customer, instead of writing the formula himself, he took the easy way out and asked ChatGPT, Timmy proceeded to copy the formula into a new calculated column.


Power BI Dashboard
Timmy`s Power BI Dashboard

Timmy noticed that the visualization showed absurd data, either Timmy was selling something else rather than marbles or there was something else going on.


Power BI Table View
Power BI Table View

Timmy proceeded to check his data model, to see that each row in the table had the same exact value for his profit's column, so what actually happened?

Timmy copied the Measure code from ChatGPT into a Calculated Column essentially creating a nested row context.

Nested Row Context
Nested Row Context?

The outer row context (built in from the Calculated Column) will iterate over each row, then for each of these rows, the inner row context (Introduced by the SUMX function) will iterate over all the rows again, essentially calculating the total profit of the entire business rather than calculating the profit for that singular row.


Interpretation In?Python:

Python Interpretation
Python Interpretation

Vice Versa

Calculated Column Formula in a Measure
Calculated Column Formula in a Measure

If Timmy copied a Calculated Column Formula into a Measure, it would not run and it will give an error, since there is no Row context introduced by a function, so the measure doesn't know which value to use for each of the columns of sale_price, cost, count.


Power BI Measures and Calculated Columns operate differently, making it essential to understand their distinct processes. Knowing how each one works is crucial for determining the right time and place to use them effectively in your data analysis and reporting.



Hurairah Chorghay

Business Intelligence | Product Analytics | Digital Marketing

4 个月

Good read! Share a part 2 with new examples. Would love to read it.

要查看或添加评论,请登录

Omar Ahmad的更多文章

  • Power BI Filter Context

    Power BI Filter Context

    What is Power BI Filter Context? Filter Contexts are Filters generated from Powerbi Visuals and Slicers that allows you…

社区洞察

其他会员也浏览了