Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello everyone,
Here is a (hopefully) simple problem that I've been struggling with on various occasions. I'll use a simple example to illustrate what I mean:
Suppose I have a table with the following columns:
Book Title | Author | Received Date
Using a relative Date Slicer (using a separate Dates table), I will have one table visual showing all books received in the last 3 months. No problem.
Now, I'd like to have a second table visual showing all books received in the same period last year.
How do I do that?
Thank you in advance!
Solved! Go to Solution.
Hi @LuukP ,
In this case you need to do for example a count rows and this depending on the columns you use will return for example 1 (if you selected a specific book), or 10 (if you aggregate by author or date) then you can use that value to filter your list.
I created the following measure:
Books previou year =
CALCULATE (
COUNTROWS(Books),
SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
)
See result below:
Has you can see I'm getting the books for current year and previous year.
If you need you can change the metric to give you a list of books or dates depending on the aggregation.
Making a small change I have created one for the books and use it in a list:
Books previou year =
CALCULATE (
CONCATENATEX(Books,Books[Book Title], ","),
SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
)
You just need to pick up one value to get the filter made for you data.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi Miguel,
Thanks for your response. The issue is that there is no value that I am trying to calculate. There is no SalesAmount or similar value, just a list of records that have a date field. So, can I do this without using a CALCULATE function?
LuukP
Hi @LuukP ,
In this case you need to do for example a count rows and this depending on the columns you use will return for example 1 (if you selected a specific book), or 10 (if you aggregate by author or date) then you can use that value to filter your list.
I created the following measure:
Books previou year =
CALCULATE (
COUNTROWS(Books),
SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
)
See result below:
Has you can see I'm getting the books for current year and previous year.
If you need you can change the metric to give you a list of books or dates depending on the aggregation.
Making a small change I have created one for the books and use it in a list:
Books previou year =
CALCULATE (
CONCATENATEX(Books,Books[Book Title], ","),
SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
)
You just need to pick up one value to get the filter made for you data.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThank you for the solution. I should note that I had to set up a one-to-many relationship between my date table and my books table - then it worked.
@LuukP ,
Forgot to mention that, I always assume that the relationship is active.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @LuukP ,
For this you need to create a measure that gets the values for the same period last year something similar to
Previous Year =
CALCULATE (
[Sales Amount],
SAMEPERIODLASTYEAR ( 'Date'[Date] )
)
This is one of the options check the links below with the explanation of this calculations and some similar.
https://www.sqlbi.com/articles/compare-equivalent-periods-in-dax/
https://www.sqlbi.com/tv/dateadd-sameperiodlastyear-dax-guide/
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsThis is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
69 | |
55 | |
37 | |
35 |
User | Count |
---|---|
85 | |
66 | |
59 | |
46 | |
45 |