Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Happy friday to everyone!
This seems like an easy DAX measure but I cant seem to work it out. I have a report showing the last week of product stock data (our lowest level of granularity in the non standard calendar). This report has slicers for users based on different product attributes. The visuals are prefiltered to show only data from the last week. But......if the user chooses from the slicers a product that was not in stock the last week, the visual adjusts to the last week that product was available (even if it was 2 years ago).
Question: how do I isolate the last week as a measure?
the calendar measure is currently:
Solved! Go to Solution.
Hi @lauralovesBI instead of
Latest week Absolute = CALCULATE(MAX(stockdata[Week]),ALL(stockdata))
try
Latest week Absolute = MAX(DateTable[Week])
Make sure you substitute the name of your date table and week number field.
Hi @lauralovesBI ,
Does last week mean the latest week before current one?
What column did you use to relate "Calendar Date" table with "stockdata" table, by [Date] column or [Week] column?
Latest week Absolute = CALCULATE(MAX(stockdata[Week]),ALL(stockdata))
[Latest week Absolute] will return the max week number from "stockdata" table. I think the max number of each year should be the same. I suggest you to add a new column [YearWeek] in your "stockdata" table, format like 202201,...202211.
YearMonth = YEAR(stockdata[Date])*100+WEEKNUM(stockdata[Date])
Then you can get the max YearWeek and Power BI won't be confused by this in calculation.
If this reply still couldn't help you solve your problem, please share a sample file with me. I need to know what does your tables look like. This will make me easier to find solution.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hi! yes, i have a star schema with a calendar table (marked as such) and product reference table. Both are connected to the stock data.
Hi @lauralovesBI this should be fairly easy then. Is weeknumber in your date table or part of the product reference table?
@littlemojopuppy - week number is part of the calendar date table and is connected to the stock data using weeks (in the same format). Product reference table is connected to stock data using product name. Thank you!
Hi @lauralovesBI instead of
Latest week Absolute = CALCULATE(MAX(stockdata[Week]),ALL(stockdata))
try
Latest week Absolute = MAX(DateTable[Week])
Make sure you substitute the name of your date table and week number field.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |