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.
I have the measure for yesterday, and I want to calculate the values for this Thursday and last Thursday using DAX. Could someone please help me
Solved! Go to Solution.
Hi @tkavitha911,
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
Hi @tkavitha911 , could you please share more details with us to help solve your issue. If it is already solved, please share the answer here and mark it 'Accept as Solution', so others with similar queries may find it easily.
Thank you.
Hi @tkavitha911 , Please let us know if your issue is solved. If it is, consider marking the answer that helped 'Accept as Solution', so others with similar queries can find it easily. If not, please share the details.
Thank you.
Hi @tkavitha911 , Please let us know if your issue is solved. If it is, consider marking the answer that helped 'Accept as Solution', so others with similar queries can find it easily. If not, please share the details.
Thank you.
Not working
Hi @tkavitha911,
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
@tkavitha911 , Try using
DAX
// Measure for This Thursday
ThisThursdayNetInventory =
CALCULATE(
[Net Inventory mUSD],
FILTER(
ALLEXCEPT('Daily Inventory', 'Daily Inventory'[Country New name], 'Daily Inventory'[Location_c], 'Daily Inventory'[Type]),
'Daily Inventory'[Date] =
VAR TodayDate = TODAY()
VAR ThisThursdayDate = TodayDate + (5 - WEEKDAY(TodayDate, 2))
RETURN ThisThursdayDate
)
)
// Measure for Last Thursday
LastThursdayNetInventory =
CALCULATE(
[Net Inventory mUSD],
FILTER(
ALLEXCEPT('Daily Inventory', 'Daily Inventory'[Country New name], 'Daily Inventory'[Location_c], 'Daily Inventory'[Type]),
'Daily Inventory'[Date] =
VAR TodayDate = TODAY()
VAR LastThursdayDate = TodayDate - WEEKDAY(TodayDate, 2) - 2
RETURN LastThursdayDate
)
)
Proud to be a Super User! |
|
I need to calculate data for the current week and the previous week, specifically focusing on Thursdays. Please provide a DAX measure to achieve this.
Hi @tkavitha911 , Thank you for reaching out to the Microsoft Community Forum.
Please try below measures:
CurrentWeekThursdayNetInventory :=
VAR YesterdayDate = MAX('Daily Inventory'[Date]) - 1
VAR DaysToThursday = 5 - WEEKDAY(YesterdayDate, 2) // 5 = Thursday in a Monday=1 calendar
VAR CurrentThursday = YesterdayDate + DaysToThursday
RETURN
CALCULATE(
[Net Inventory mUSD],
FILTER(
ALLEXCEPT(
'Daily Inventory',
'Daily Inventory'[Country New name],
'Daily Inventory'[Location_c],
'Daily Inventory'[Type]
),
'Daily Inventory'[Date] = CurrentThursday
),
NOT ISBLANK('Daily Inventory'[Date])
)
PreviousWeekThursdayNetInventory :=
VAR YesterdayDate = MAX('Daily Inventory'[Date]) - 1
VAR DaysToThursday = 5 - WEEKDAY(YesterdayDate, 2)
VAR PreviousThursday = YesterdayDate + DaysToThursday - 7
RETURN
CALCULATE(
[Net Inventory mUSD],
FILTER(
ALLEXCEPT(
'Daily Inventory',
'Daily Inventory'[Country New name],
'Daily Inventory'[Location_c],
'Daily Inventory'[Type]
),
'Daily Inventory'[Date] = PreviousThursday
),
NOT ISBLANK('Daily Inventory'[Date])
)
If this helped solve the issue, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details, always happy to help.
Thank you.
User | Count |
---|---|
25 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
25 | |
12 | |
11 | |
10 | |
6 |