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.
Hello,
I have a table with two value A & B. each them is group by data and segment.
I have to get the variation between the values A & B between the different Quarter and displayed only for the current date.
i made this DAX query but does not work correcly:
VariationTest =
VAR __mostRecentVisibleDate =
CALCULATE ( MAX ( Calendrier[Date] ); ALLSELECTED ( 'Calendrier' ) )
VAR __previousVisibleDate =
PREVIOUSQUARTER(Calendrier[Max Date])
VAR A = [sumamount]
VAR B =
CALCULATE (
[sumamount];
ALLSELECTED ( 'Calendrier' );
Calendrier[Date] = __previousVisibleDate
)
VAR __variancePercent =
DIVIDE ( B - A ; A )
RETURN
IF (
MAX ( Calendrier[Date] ) = __mostRecentVisibleDate;
__variancePercent
)
As PREVIOUSQUARTER does not take directly __mostRecentVisibleDate, I create Max Date column with
Max Date = MAX(Calendrier[Date])
Can someone help on this please.
Thank you in advance
Thank you very much, I will try that
Hi @salemhaddad
Please try the following Dax:
VariationTest =
VAR __mostRecentVisibleDate =
MAXX(
ALLSELECTED('Calendrier'),
'Calendrier'[Date]
)
VAR __startOfQuarter =
STARTOFQUARTER(__mostRecentVisibleDate)
VAR __startOfPreviousQuarter =
STARTOFQUARTER(
EDATE(__mostRecentVisibleDate, -3)
)
VAR CurrentQuarterAmount =
CALCULATE(
[sumamount],
DATESBETWEEN(
'Calendrier'[Date],
__startOfQuarter,
__mostRecentVisibleDate
)
)
VAR PreviousQuarterAmount =
CALCULATE(
[sumamount],
DATESBETWEEN(
'Calendrier'[Date],
__startOfPreviousQuarter,
EDATE(__startOfQuarter, -1)
)
)
VAR __variancePercent =
DIVIDE(
PreviousQuarterAmount - CurrentQuarterAmount,
CurrentQuarterAmount
)
RETURN
IF(
MAX('Calendrier'[Date]) = __mostRecentVisibleDate,
__variancePercent,
BLANK()
)
Best Regards,
Jayleny
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
8 | |
7 |