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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
stoic1618
New Member

Slice by dates for Each Year

Hi, 

I wish to calculate the total revenue for a specific time period for each year. So if I have data for 4 years 2014, 2015, 2016, and 2017, I want to be able to check the total revenue generated in each year from say, Jan 25th to July 25th. The time period can be entered by user, so it's adjustable. I came across a lot of posts regarding year to date calculation, but most of them were for fixed time periods or quarters. So I thought I'd post here to know for sure if there's a way to do this on power bi

 

Thanks 

1 ACCEPTED SOLUTION

Hi @stoic1618,

 

You can refer to below sample to achieve your requirement.

 

1. Creata a table as the source of slicer.(month no)

Selector = SELECTCOLUMNS(VALUES('Table'[Date].[MonthNo]),"Month",[Date].[MonthNo]) 

2. Write a measure to calculate based on slicer.

dynamic = 
var select_Min=MINX(ALLSELECTED(Selector[Month]),[Month])
var select_Max=MAXX(ALLSELECTED(Selector[Month]),[Month])
return
CALCULATE(SUM('Table'[Amount]),FILTER(ALLSELECTED('Table'),[Date]>=DATE(MAX('Table'[Date].[Year]),select_Min,1)&&[Date]<=DATE(MAX('Table'[Date].[Year]),select_Max,1)))

 

3. Create the bar chart and slicer.

1.PNG

 

Result:

3.PNG

 2.PNG

 

 

Regards,

XIaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
GilbertQ
Super User
Super User

Hi @stoic1618

 

What you could do is to use the Date Slicer which will then enable your user to use the slider to decide the date range that he wants to use.

 

With the above you would only require one measure which would be you Total Revenue. Then as they change the Date Slider it will reflect the Total Revenue for that period?





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

Proud to be a Super User!







Power BI Blog

Sorry, I was probably not clear in my question. The problem with using a date slicer was it wouldn't let me select just the date (of the month) and month. I had to select the entire date (along with the year). So that would filter the data for that particular year. This image should probably help: 

 

temp solution.PNG

 

This is what I'm doing for now as a temporary solution. As you can see, I want the revenue for each year, and I have selected it for some particular months. I want to be able to do that for any date (date and month).. I couldn't make the date slicer filter by just the date and month.  

 

 

 

Hi @stoic1618,

 

You can refer to below sample to achieve your requirement.

 

1. Creata a table as the source of slicer.(month no)

Selector = SELECTCOLUMNS(VALUES('Table'[Date].[MonthNo]),"Month",[Date].[MonthNo]) 

2. Write a measure to calculate based on slicer.

dynamic = 
var select_Min=MINX(ALLSELECTED(Selector[Month]),[Month])
var select_Max=MAXX(ALLSELECTED(Selector[Month]),[Month])
return
CALCULATE(SUM('Table'[Amount]),FILTER(ALLSELECTED('Table'),[Date]>=DATE(MAX('Table'[Date].[Year]),select_Min,1)&&[Date]<=DATE(MAX('Table'[Date].[Year]),select_Max,1)))

 

3. Create the bar chart and slicer.

1.PNG

 

Result:

3.PNG

 2.PNG

 

 

Regards,

XIaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.