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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
datadonuts
Advocate II
Advocate II

Turn a calculated column into a measure

I am working on a very simple datamodel to transfer a calculated column from a table into a measure.

It was pretty easy to create a calculated column in my fact table, but actually I want to avoid that and only work with DAX measures.

 

The tables are fSales and disDiscount. No relationship between them.

 

My calculated column function is:

 

Discounted product price

=ROUND(

LOOKUPVALUE(

dProduct[Price],[Product],fSales[Product])*

(1-CALCULATE(

MAX(disDiscount[Discount]),

FILTER(

disDiscount, fSales[Quanity]>=disDiscount[Units]))),2)

 

 

The result using a calculated columns looks like this. How to get the same result only using DAX measures?

(the related product price is just from a related product table USING [Product])

 

It works as calculated column  but not as measure??? 😫

 

datadonuts_3-1595790852405.png

 

Files (from excel)

 

datadonuts_0-1595790626973.png

 

datadonuts_1-1595790661944.png

 

Annotation 2020-07-26 212649.jpg

 

 

 

 

 

 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4 REPLIES 4
datadonuts
Advocate II
Advocate II

Thanks for all your support. I figured out a solution. Is that a reasonable one? What other solutions are possible/easier/better?

 

Annotation 2020-07-27 232927.jpg

 

 

 

 

 

 

 

 

 

 

 

Annotation 2020-07-27 232745.jpg

 

 

 

 

 

 

Annotation 2020-07-27 232001.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

amitchandak
Super User
Super User

@datadonuts , as there are one many relations, you should be able to use

related(dProduct[Price])

sumx(sales, sales[qty]*related(dProduct[Price]) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
lbendlin
Super User
Super User

Don't forget what calculated columns are for, and what measures are for

 

calculated columns:  when your computation is only dependent on the source data but not on any user filter choices.

Calculated columns are computed only once during query refresh. After that they are static and part of the expanded tables.

They are computed in the true row context of your query data. 

 

Measures: are computed dynamically whenever the user filter choices change. Every single time.  They operate on the filter context of the expanded tables, but are not part of them.

 

That means a DAX function that worked for a calculated column will most likely not work in a measure, at least not with the same result.  

 

First you need to decide if you truly need a measure. If so then you need to rewrite your DAX specifically for the goals of that measure (including the tricky parts for totals etc). Use variables to prevent the filter context transitions to mess with your data (and for better legibility)

 

az38
Community Champion
Community Champion

@datadonuts 

smth like this

Discounted product price = 
VAR CurrentProduct = MAX(fSales[Product])

RETURN

ROUND(
CALCULATE(MAX(dProduct[Price]),[Product] = CurrentProduct )
*
(1-CALCULATE(
MAX(disDiscount[Discount]),
FILTER(
disDiscount, fSales[Quanity]>=disDiscount[Units]))),2)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.