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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
wilberk
Frequent Visitor

User entered date with comparison column for previous year

I am trying to have a custom date range that the user can enter dates and I want a column that shows the values for that current date range and a second column that shows the values for that month/day but for the previous year. So for example I have a sold date set to 6/1/2023- 6/15/2023 that the user entered and a column showing this year sold amount of 1000. I want the second column to show the sold amount of last year 6/1/2022-6/15/2022 lets say 800. I am trying to use a matrix visual to do this and have slicers for users to choose their start and end date. I have experience with tableau so there I could enter a date parameter and set calculations to compare to the start and end date parameters and subtract a year from those parameters that the users were entering themselves. Looking for something similar in power bi. 

1 ACCEPTED SOLUTION

How do you prevent the user from selecting a range that reaches across years?  What should happen if they select 2022-10-01 to 2023-02-28  ?

 

See attached for a standard approach using SAMEPERIODLASTYEAR

 

lbendlin_0-1689117709809.pnglbendlin_1-1689117751111.png

 

 

 

View solution in original post

9 REPLIES 9
lbendlin
Super User
Super User

a custom date range that the user can enter dates
I am trying to use a matrix visual to do this and have slicers for users to choose their start and end date.

These statements are ambiguous. Are you planning to allow your users to manually enter a date, or are you restricting them to have to select an existing date?

I want the user to manually enter the date they desire for this year and get the comparison between this year and last years data in the matrix 

 wilberk_0-1688995065020.png

 

There is no good visual for manually entering data in Power BI.  Will you be using the filter pane with advanced mode filters?

If there is a way for it to work with the filter pane with advanced mode filters I can use that. 

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

Sample Data:

clothing groupclothing category date of purchaseAmount
shirts long sleeve shirt4/15/20223
shirts short sleeve shirt4/16/20226
shirts tang top 5/16/20224
shirts long sleeve shirt6/1/20223
shirts short sleeve shirt7/1/202210
shirts tang top 7/2/202212
shirts long sleeve shirt4/15/20235
shirts short sleeve shirt4/16/202330
shirts tang top 5/16/20237
shirts long sleeve shirt6/1/20238
shirts short sleeve shirt7/1/20239
shirts tang top 7/2/20238
pantsjeans4/15/202257
pantsshorts4/16/20226
pantsleggings 5/16/20224
pantsjeans6/1/20223
pantsshorts7/1/202210
pantsleggings 7/2/202212
pantsjeans4/15/20235
pantsshorts4/16/202320
pantsleggings 5/16/20237
pantsjeans6/1/20238
pantsshorts7/1/202319
pantsleggings 7/2/20238

 

Expected outcome:

wilberk_0-1689084397225.png

 

How do you prevent the user from selecting a range that reaches across years?  What should happen if they select 2022-10-01 to 2023-02-28  ?

 

See attached for a standard approach using SAMEPERIODLASTYEAR

 

lbendlin_0-1689117709809.pnglbendlin_1-1689117751111.png

 

 

 

The desired result if they select 2022-10-01 to 2023-02-28 would be for the previous year column to show 2021-10-01 to 2022-02-28

Good - that's what my proposal based on SAMEPERIODLASTYEAR does.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.