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

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

Reply
yoav20007
Helper II
Helper II

How to convert calculate IF DAX statement column to measure?


Hi,
how to write the measure of IF function?
i succeeded just calculate column.
i wont to use a measure instead of calculate column

This calculate column work
sum_if_true2 = IF((sh[asmbly])=TRUE(),[total sale],0)

This dax doesn't work
sum_if_true = IF(VALUES(sh[asmbly])=TRUE(),[total sale],0)

Thanks
if_dax.JPG

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @yoav20007,


You can try below formula, I use 'lastnonblank' function to get current row contents:

sum_if_true2 =
VAR _current =
    LASTNONBLANK ( sh[asmbly], [asmbly] )
RETURN
    IF ( _current, [total sale], 0 )

 

Reference link:

LASTNONBLANK Function (DAX)

 

Regards,
Xiaoxin Sheng

View solution in original post

Thank you @Anonymous

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

 

Try this

 

=CALCULATE(SUM(sh[sales]),FILTER(sh,sh[asmbly]=TRUE()))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi @yoav20007,


You can try below formula, I use 'lastnonblank' function to get current row contents:

sum_if_true2 =
VAR _current =
    LASTNONBLANK ( sh[asmbly], [asmbly] )
RETURN
    IF ( _current, [total sale], 0 )

 

Reference link:

LASTNONBLANK Function (DAX)

 

Regards,
Xiaoxin Sheng

Thank you @Anonymous

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors