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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Fcoatis
Post Patron
Post Patron

Convert calculated column into measure

Hello, I have the following calculated column in a table called 'Admin':

 

Diff = [Quantidade]-LOOKUPVALUE(
					Admin[Quantidade],Admin[Código],[Código],Admin[Data],
					CALCULATE(
						Max(Admin[Data]),
						FILTER(
							Admin,Admin[Código]=EARLIER(Admin[Código])&&Admin[Data]<EARLIER(Admin[Data])
						)
					)
				)

I can´t figure it out as a measure. Please help

 

TIA

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

@Fcoatis , you may want to try,

Delta = 
VAR __dt = MAX ( Admin[Data] )
VAR __tb =
    TOPN (
        1,
        CALCULATETABLE ( Admin, ALLEXCEPT ( Admin, Admin[Código] ), Admin[Data] < __dt ),
        Admin[Data]
    )
RETURN
    MAX ( Admin[Quantidade] ) - MAXX ( __tb, Admin[Quantidade] )

Screenshot 2021-02-19 204603.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

5 REPLIES 5
negi007
Community Champion
Community Champion

@Fcoatis When you use column or calculated column in your measure, you have to use it with some aggreage function like sum, max, min, count etc. 

in calculated column you can use directly column name without using aggreage function.

 

for specify solution of your problem, you may share your powerbi file.




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

amitchandak
Super User
Super User

@Fcoatis ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

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

@amitchandak Here it is.

 

Thank you

CNENFRNL
Community Champion
Community Champion

@Fcoatis , you may want to try,

Delta = 
VAR __dt = MAX ( Admin[Data] )
VAR __tb =
    TOPN (
        1,
        CALCULATETABLE ( Admin, ALLEXCEPT ( Admin, Admin[Código] ), Admin[Data] < __dt ),
        Admin[Data]
    )
RETURN
    MAX ( Admin[Quantidade] ) - MAXX ( __tb, Admin[Quantidade] )

Screenshot 2021-02-19 204603.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Thank you, thats it.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.