Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
PowerWhy
Helper III
Helper III

Display row headers that reflect the year prior to the one selected in the slicer

Hello,

 

For a table visual please could you tell me how to display row headers for the prior year if I select the current year in a slicer? I've upload the pbix file to https://file.io/BlbmPmmHvb9E 

 

i.e. if I select 2024 in the slicer I should see the customers from 2023 (i.e. "D" should also be visible).

 

I know how to change the filter context of the "Amount" to the prior year but I'm stumped how to control the row headers to make customer "D" also appear if I select year 2024. 

 

1. Dataset.PNG2. 2024 slicer.PNG3. 2023 slicer.PNG

 

 

Many thanks for any help!

 

PW

1 ACCEPTED SOLUTION

Brilliant thank you Audrey! 🙂 Sorry why did the slicer need the year from the date hierachy rather than just the date for the "D" row header to show?

View solution in original post

7 REPLIES 7
audreygerred
Super User
Super User

Hello! Ideally you will have a star schema with a date dimension table, but you can achieve what you need even without one.

 

I created a table that has you data, but instead of just the year, I have a date. You will need an actual date for this to work, so if you do not have actual months and days just create a new column in Power Query that creates a date (just pick any date, like December 31 and concatenate with the year so that you have a date field).

 

Once you have your date field, create a measure for Amount. Total Amount = SUM('YourTable'[Amount])

Next, create the measure for prior year. Total Amount PY = CALCULATE([Total Amount], SAMEPERIODLASTYEAR('YourTable'[Date].[Date]))  <-- if you do have a date dim table and it's marked as date table the syntax would be ('YourTable'[Date]).

 

Now that you have these measures, in your visual if you put the Total Amount PY measure in the visual and filter to 2024, the 2023 figures will show (including D). You can even show them both so users can easily see where you lost or gained a customer.

audreygerred_0-1721922825899.png

audreygerred_1-1721922853995.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Thank you Audrey but for some reason I am still not seeing the customer "D" have I misunderstood something? (pbix file: https://file.io/DXz6tuchkE3C )

 

PowerWhy_1-1721994867942.png

 

Hello - I do not see the file you mentioned - it says deleted. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Apologies please can you try https://file.io/8ZldlcJuHFPT ?

Hello! I found the issue. In my earlier response for PY I provided this:

Total Amount PY = CALCULATE([Total Amount], SAMEPERIODLASTYEAR('YourTable'[Date].[Date]))  <-- if you do have a date dim table and it's marked as date table the syntax would be ('YourTable'[Date]).

 

In your file, you used the syntax for your previous year calculation as for when you have a date dimension table, however, since you don't have a date dim table, you need to use the syntax I provided for that. I updated your measure from:

Amount PY = CALCULATE([Total Amount], SAMEPERIODLASTYEAR('Data'[Date]))
to
Amount PY = CALCULATE([Total Amount], SAMEPERIODLASTYEAR('Data'[Date].[Date]))
 
I also put year in the slicer instead of the whole date. 
audreygerred_0-1722009245141.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Brilliant thank you Audrey! 🙂 Sorry why did the slicer need the year from the date hierachy rather than just the date for the "D" row header to show?

Hi! It doesn't work with date - it needs the hierarchy.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.