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 trying to write a DAX based on the below SQL query logic. But struggilling in the date patrt. Any help would really appriciated.
SELECT IIF(Month(estimated_close_date)=1 AND Year(estimated_close_date) = Year(getdate())-1,
Sum(price_per_unit*quantity)+
Sum(onetime_charge),IIF(Year(estimated_close_date) = Year(getdate())-1 AND
(estimated_close_date < estimatedendbilldate) AND
Month(estimated_close_date) <1 AND
(Month(estimated_close_date)+IIF(contract_period_unit=2,contract_period,
IIF(contract_period_unit=3,contract_period.Value*12,0)))>1,
(Sum(price_per_unit*quantity)),0)) AS JAn
from xyx
Many thanks Advance
@Anonymous
Try this below dax
JAn :=
VAR YearToDate = YEAR(TODAY()) - 1
VAR LastDayOfYear = DATE(YEAR(TODAY()) - 1, 12, 31)
VAR EstimatedCloseDate = EARLIER(xyx[estimated_close_date])
VAR EstimatedEndBillDate = EARLIER(xyx[estimatedendbilldate])
VAR ContractPeriodUnit = EARLIER(xyx[contract_period_unit])
VAR ContractPeriod = EARLIER(xyx[contract_period])
RETURN
IF(
MONTH(EstimatedCloseDate) = 1 &&
YEAR(EstimatedCloseDate) = YearToDate,
SUM(xyx[price_per_unit] * xyx[quantity]) +
SUM(xyx[onetime_charge]),
IF(
YEAR(EstimatedCloseDate) = YearToDate &&
EstimatedCloseDate < EstimatedEndBillDate &&
MONTH(EstimatedCloseDate) < 1 &&
MONTH(EstimatedCloseDate) + IF(
ContractPeriodUnit = 2,
ContractPeriod,
IF(
ContractPeriodUnit = 3,
ContractPeriod.Value * 12,
0
)
) > 1,
SUM(xyx[price_per_unit] * xyx[quantity]),
0
)
)
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
24 | |
9 | |
7 | |
6 | |
6 |
User | Count |
---|---|
29 | |
11 | |
11 | |
10 | |
6 |