Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
Solved! Go to Solution.
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
Thank You!
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
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
19 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
25 | |
10 | |
10 | |
9 | |
6 |