Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi all
Trying to filter to Last week's items as follows:
Period Lookup Table Filters Items Data Table - One to Many
Solved! Go to Solution.
// Of course the one with hard-coded values works.
// I have already explained it in my first post.
// If you read it carefully, you'd know what to do...
[LastWeekItems] =
var __lastWeek = [LastWk]
return
Calculate (
[TotalItems],
WeekofYr = __lastWeek,
Year = 2020 // this should not be hard-coded
)
You are not showing us everything, @AviBI. What do you mean by "I defined a couple of variables in the Period Lookup Table"? This makes little sense. You can create variables in a formula, not in a table. Secondly, you can use variables in your measure formula instead of the hard-coded values in exactly the same places but the variables MUST be defined in the measure itself, not outside. Remember that the syntax you're using is syntax sugar since all conditions under CALCULATE must be tables. So, this:
calculate(
[measure],
T[Col] = a
)is always translated into:
calculate(
[measure],
filter(
all( T[Col] ),
T[Col] = a
)
)"a" must be a value, can't be a measure, for instance.
// Of course the one with hard-coded values works.
// I have already explained it in my first post.
// If you read it carefully, you'd know what to do...
[LastWeekItems] =
var __lastWeek = [LastWk]
return
Calculate (
[TotalItems],
WeekofYr = __lastWeek,
Year = 2020 // this should not be hard-coded
)
I did read your last post and did not quite understand as I am only used to defining straight forward measures (don't even know how to use "var" etc.)
Also understand that 2020 needs to be treated in a similar way as the week numbers. so I'll need to follow the same approach for the year as well
Thanks a lot for your help. I will now try this
This is the end result I am after - but I have acheived this using manual filters and I do not want to update the filters every week. This should be automated.
Common field between Calendar & Data (Items Table) is "Period"
Measures:
This is exactly what I need.
Now in order to get to Last weeks items through a measure approach (not manual filters), this is how I think the measure should look like:
LastWeekItems = Calculate (TotalItems , WeekofYr = LastWk , Year = 2020)
This does not work. "Calculate" can not be used with True/False error
This however works:
LastWeekItems = Calculate (TotalItems, WeekofYr = 31, Year = 2020)
Now you may tell me that I am going about it all wrong which is fine. I just need the report to pickup the last week, and display the items on a daily basis (as shown above) and I need this to happen automatically based on the data and relationships (as above)
Hope this gives all the info you required to help
@amitchandak @Anonymous @Greg_Deckler
@AviBI , see if these can help
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
else
Can you share sample data and sample output in table format?
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 21 | |
| 10 | |
| 7 | |
| 7 |