March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
Register NowGet certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Solved! Go to Solution.
Hi @Anonymous ,
Thanks for the reply from @rajendraongole1 , please allow me to provide another insight:
You can try this.
Sales Same Week Last Year =
VAR CurWeek = WEEKNUM(TODAY(), 21)
VAR CurYear = YEAR(TODAY())
VAR SameWeekLastYear = CurWeek
VAR LastYear = CurYear - 1
RETURN
SUMX(
FILTER(
ALL(Time),
Time[number week] = SameWeekLastYear && Time[Year] = LastYear
),
[Sold]
)
If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Have you solved your problem? If so, can you share your solution here and mark the correct answer as a standard answer to help other members find it faster? Thank you very much for your kind cooperation!
Best Regards,
Clara Gong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous -Create a measures to avoid issues with context and gaps in the Week Rank, i am using EARLIER function to correctly refer to the previous week.
Sales Previous Week =
CALCULATE(
[Sales],
FILTER(
ALL(Time),
Time[Week Rank] = MAX(Time[Week Rank]) - 1
)
)
create a measure for previous Week Last Year:
Sales Previous Week Last Year =
VAR CurrentWeekRank = MAX(Time[Week Rank])
VAR PreviousWeekRankLastYear =
CALCULATE(
MAX(Time[Week Rank]),
FILTER(
ALL(Time),
Time[Year] = MAX(Time[Year]) - 1 &&
Time[Week Rank] < CurrentWeekRank
)
)
RETURN
CALCULATE(
[Sales],
FILTER(
ALL(Time),
Time[Week Rank] = PreviousWeekRankLastYear &&
Time[Year] = MAX(Time[Year]) - 1
)
)
check the above measure still returns any blanks. Hope it works
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
where did you use EARLIER? i don't see it, thank you!
Hi @Anonymous - The EARLIER function isn't directly used in the above dax funtion but can be helpful in some scenarios for row contect. we can use direct approach with variables to handle context and gaps in the Week Rank effectively.
try with above measure and let me know.
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Proud to be a Super User! | |
i wrote this function and now it works, for sales past week
Hi @Anonymous ,
Thanks for the reply from @rajendraongole1 , please allow me to provide another insight:
You can try this.
Sales Same Week Last Year =
VAR CurWeek = WEEKNUM(TODAY(), 21)
VAR CurYear = YEAR(TODAY())
VAR SameWeekLastYear = CurWeek
VAR LastYear = CurYear - 1
RETURN
SUMX(
FILTER(
ALL(Time),
Time[number week] = SameWeekLastYear && Time[Year] = LastYear
),
[Sold]
)
If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
Check out the November 2024 Power BI update to learn about new features.
User | Count |
---|---|
60 | |
31 | |
22 | |
21 | |
20 |