Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello all
I have a table with week number, Sales, Costs and profits.
I would love to see, only the last 4 weeks, like this example, which are filtered from the date filter:
Thanks in advance guys
Best regards
Pedro
Solved! Go to Solution.
Hi @Anonymous ,
We can use two ways to meet your requirement.
1. Create a calculate column first to get the week number.
week = RIGHT('Table'[year&week],LEN('Table'[year&week])-FIND("-",'Table'[year&week],1,1))
Then we can create a measure based on [week].
Measure =
var last_week = MAXX(ALLSELECTED('Table'),'Table'[week])
var Last_four_week = last_week-4
return
CALCULATE(SUM('Table'[values]),FILTER('Table','Table'[week]>Last_four_week && 'Table'[week]<=last_week))
And we can put the [year & week] and [Measure] in a table visual.
2. We can use Filters on this visual to get the result.
Also we need the week number column.
Then we create a table and configure the [year & week]’s filter and put the [week] on By value.
The result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
We can use two ways to meet your requirement.
1. Create a calculate column first to get the week number.
week = RIGHT('Table'[year&week],LEN('Table'[year&week])-FIND("-",'Table'[year&week],1,1))
Then we can create a measure based on [week].
Measure =
var last_week = MAXX(ALLSELECTED('Table'),'Table'[week])
var Last_four_week = last_week-4
return
CALCULATE(SUM('Table'[values]),FILTER('Table','Table'[week]>Last_four_week && 'Table'[week]<=last_week))
And we can put the [year & week] and [Measure] in a table visual.
2. We can use Filters on this visual to get the result.
Also we need the week number column.
Then we create a table and configure the [year & week]’s filter and put the [week] on By value.
The result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-zhenbw-msft
Many thanks for your solution. It's the only one that works the way that i want,....but i've already decided for your second solution.
The first one, works also, i've tried it.
THank you so much
Best regards
Pedro
I would first set up a week index in my calendar. Then I would set up a new column that was "IsLast4Wks" and I would use this column to filter on the visual. I'm not sure if it is the most efficient way to do it, but I use it for viewing similar based on months.
Hi @Anonymous
Sounds a good idea. Can you share with me how to set those things up, even the way you do it for months?
Very good
I first set-up my week index like below using a "sort" column.
Following that, I have a column for "last3months" as shown below,
I would then put in a filter for "last3months" = yes in the visual.
Hope that helps.
I'm sorry @Anonymous but maybe i did miss something....i don't have any column or measure in my date table named sort.
Can you help?
Sorry, I am not sure if that is even necessary. But my calendar date column is "calendardate[date]" and then I have another column called "Sort" which is just,
Try like
Measure =
var _max = maxx(allselected('Date'),'Date'[Date])
var _min = _max+-1*WEEKDAY(_max,2)+1 -21 //or -28
return
calculate(Table[Value],filter(all('Date'),'Date'[Date]>=_min && 'Date'[Date]<=_max))
Hey Amit
Thanks for the answer.
This measure will give me the total for this periode (21 days) and i'd love a total for each week, like my pic.
Is it possible?
Hello
It seems to be a good solution, even for months and quarters.
Can you help me on that? I really don't know how....
Thanks in advance
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
87 | |
87 | |
84 | |
66 | |
49 |
User | Count |
---|---|
130 | |
110 | |
93 | |
70 | |
67 |