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.
How to convert this sql query to DAX in a measure
Select value from KPI A
where period in (
select B.period from
Time B join period C
on B.period=c.Period
where b.quater >= c.quater-1 and b.quater <= c.quater-5
DAX measure:
Selected Value =
VAR CurrentQuarter = MAX('Period'[Quarter])
VAR FilteredPeriods =
FILTER(
ALL('Time'),
'Time'[Quarter] >= CurrentQuarter - 5 &&
'Time'[Quarter] <= CurrentQuarter - 1
)
RETURN
CALCULATE(
MAX('KPI A'[Value]),
'KPI A'[Period] IN DISTINCT(SELECTCOLUMNS(FilteredPeriods, "Period", 'Time'[Period]))
)
💌 If this helped, a Kudos 👍 or Solution mark ✅ would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn
Hi, @pavithrarajan
May I ask if your problem is solved? If not resolved, can you provide sample data and your expected output? This will better describe your problem. How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Try this -
Measure =
CALCULATE(
SUM('KPI A'[value]),
FILTER(
'KPI A',
'KPI A'[period] IN
SELECTCOLUMNS(
FILTER(
CROSSJOIN('Time', 'period'),
'Time'[period] = 'period'[Period] &&
'Time'[quarter] >= 'period'[quarter] - 1 &&
'Time'[quarter] <= 'period'[quarter] - 5
),
"period", 'Time'[period]
)
)
)
Proud to be a Super User! | |
User | Count |
---|---|
73 | |
70 | |
38 | |
24 | |
23 |
User | Count |
---|---|
96 | |
94 | |
50 | |
42 | |
40 |