- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

How to show past X years by Qtr using DAX
Hello,
Looking some help to achive last X year (at least 5 years) data using DAX? (Snip below on the format). Currently I am using one measure for each year and works fine if I am selecting "2024" from the slicer above but as soon as I select any other year numbers change and doesn't show what column hearders are. I need to show this by Qtr. Would really appriciate help on this.
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Can you share some data ?
Proud to be a Power BI Super User !
Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First you need to create a table with the distinct values of your Years :
YearsTable =
VAR UniqueYears = DISTINCT ( SELECTCOLUMNS ( Consolidated_Sales_From_2019, "Year", YEAR ( [Date] ) ) )
RETURN
UniqueYears
Don't create any relationship between your fact table and the Years table :
Then create your measure for Sales :
Sales = CALCULATE(SUM(Consolidated_Sales_From_2019[Actual Sales]))
Create another measure to use it as a filter on the visual :
Sales Last 5 Years =
IF(MAX(Consolidated_Sales_From_2019[Year])>(MAX(YearsTable[Year])-5) &&
MAX(Consolidated_Sales_From_2019[Year])<=MAX(YearsTable[Year]),1,0)
For the Year slicer, use the YearsTable (you may need to check your Quarter column):
Proud to be a Power BI Super User !
Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @AmiraBedh ,
I tried many different ways but wasn't able to succed to send you PBIX file or data on excel or thru table or notepad. So below I copied the data for one year, so if you copy the data 5/6 times and change the year, that will create a data for few years for you to test. Thanks in advance!
2019 | Actuals | 4/1/2019 | 1 | 2 | AD | 1000 | 1000 | 1000L Tote | LT | Q2 | Apr | 4 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
2019 | Actuals | 6/1/2019 | 1 | 2 | AD | 1000 | 1000 | 1000L Tote | LT | Q2 | Jun | 6 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
2019 | Actuals | 5/1/2019 | 1 | 2 | AD | 1000 | 1000 | 1000L Tote | LT | Q2 | May | 5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
2019 | Actuals | 8/1/2019 | 1 | 2 | AD | 1000 | 1000 | 1000L Tote | LT | Q3 | Aug | 8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Can you share some data ?
Proud to be a Power BI Super User !
Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources
Subject | Author | Posted | |
---|---|---|---|
09-22-2023 02:22 AM | |||
Anonymous
| 09-07-2022 11:21 AM | ||
02-07-2024 01:57 AM | |||
11-22-2023 08:48 AM | |||
Anonymous
| 02-03-2021 02:22 AM |
User | Count |
---|---|
135 | |
123 | |
83 | |
61 | |
46 |