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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
leerjones85
Frequent Visitor

Help with IF DAX Measure

Hi,

 

I am new to Power BI and have got stuck when creating a measure.

 

I have a fact table the following columns

 

'FACT_METRICS'[DATE]

'FACT_METRICS'[ACTUAL]

'FACT_METRICS'[TARGET]

 

I have a dimension table with the following

 

'DIM_DATE'[DATETIME]

'DIM_DATE'[DAY_MINUS]

 

I am wanting to create a measure than returns the following

 

IF 'FACT_METRICS'[DATE] < 'DIM_DATE'[DATETIME] WHERE 'DIM_DATE'[DAY_MINUS] = "Today" THEN CALCULATE(SUM('FACT_METRICS'[ACTUAL]) - SUM('FACT_METRICS'[TARGET])) ELSE SUM('FACT_METRICS'[TARGET])

 

Any help is much appreciated,

 

Thanks

1 ACCEPTED SOLUTION
shafiz_p
Super User
Super User

Hi @leerjones85 It sounds like you’re trying to create a measure that compares dates and calculates different sums based on the condition. Here’s how you can achieve this in DAX:

To get today's date:

TodayDate = 
CALCULATE(
    MAX('DIM_DATE'[DATETIME]),
    'DIM_DATE'[DAY_MINUS] = "Today"
)

Main measure:

Actual vs Target Measure = 
IF(
    MAX('FACT_METRICS'[DATE]) < [TodayDate],
    CALCULATE(
        SUM('FACT_METRICS'[ACTUAL]) - SUM('FACT_METRICS'[TARGET])
    ),
    SUM('FACT_METRICS'[TARGET])
)

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

View solution in original post

2 REPLIES 2
leerjones85
Frequent Visitor

Thank You!

shafiz_p
Super User
Super User

Hi @leerjones85 It sounds like you’re trying to create a measure that compares dates and calculates different sums based on the condition. Here’s how you can achieve this in DAX:

To get today's date:

TodayDate = 
CALCULATE(
    MAX('DIM_DATE'[DATETIME]),
    'DIM_DATE'[DAY_MINUS] = "Today"
)

Main measure:

Actual vs Target Measure = 
IF(
    MAX('FACT_METRICS'[DATE]) < [TodayDate],
    CALCULATE(
        SUM('FACT_METRICS'[ACTUAL]) - SUM('FACT_METRICS'[TARGET])
    ),
    SUM('FACT_METRICS'[TARGET])
)

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.