BillK
July 6, 2020, 7:27pm
1
I am trying to do the following.
I want to create a matrix. In the rows, I want the dates for the last 7 days. In the values section I want the sum of transactions.
I’m looking for something like this…
(** notice since there are no transactions on the weekend, June 27 and June 28 are not on a row**)
When I first tried this, I put a filter on the visual using the Day Offset in my calendar table. Basically Calendar[Day Offset]>=-7.
The problem is that a blank date shows up on the top of the matrix, with a sum of all the transactions beyond the 7 days. It looks like this…
(**Also the total is for all transaction dates not just the last 7 days)
Thanks for the help
@BillK ,
Give this a go:
Transactions Last 7 Days =
CALCULATE(
COUNTROWS( Sales ),
FILTER(
Dates,
Dates[Date] <= TODAY() &&
Dates[Date] >= TODAY() - 6
)
)
I hope this is helpful. Full solution file below.
In addition, you can also set up a Period table in Power Query, Jarrett has posted all details here.
All,
Here is a solution that I use on most of my models regarding a dynamic date range slicer. I found the solution from Chris Webb, from this blog post:
I changed up his solution a bit to match the solution I wanted. In order to set this up, you’ll need 2 different sets of M code. Read the blog to understand fully how this is done, but I wanted to point out that an important feature in the setup is the Relationship between the Table and the “Date Table”, Make sure in this case to have the Cr…
.
I hope this is helpful.
BillK
July 6, 2020, 9:50pm
4
BrianJ,
Thanks. Exactly what I needed.
Bill
BrianJ
July 6, 2020, 10:05pm
5
@BillK ,
. Great- glad to hear that worked well for you.
BillK
July 7, 2020, 12:24am
6
Melissa,
Thank you for posting this. It is really exciting. This opens up a huge range of possibilities. It will take me some time to figure it out, but knowing it is possible and having the roadmap is a huge help.
Regards,
Bill
1 Like