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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
JS00
Frequent Visitor

Calculate Change and % Change based on Slicer Selection

Hello,

 

I have a sales table and a date slicer. 

I want to be able to let user choose two dates from the slicer and the Change and % Change column would calculate base on what the users select. Can anyone give me some pointers?

 

Thank you. 

 

JS00_0-1710875658377.png

 

2 ACCEPTED SOLUTIONS
samratpbi
Super User
Super User

Hi, what I have done is, created below sample data first.

samratpbi_0-1710881209839.png

Then created a slicer on date column.

samratpbi_1-1710881274158.png

Then created below measures:

Sales Max selected date =
CALCULATE(
    SUM(DatePoint[Sales]),
    DatePoint[Sales Date] = MAX((DatePoint[Sales Date]))
)
Sales Min selected date =
CALCULATE(
    SUM(DatePoint[Sales]),
    DatePoint[Sales Date] = MIN((DatePoint[Sales Date]))
)
above measures will give me values for max and min selected dates. If no dates selected, then max and min values from overall dates.
Now create a difference measure:
Sales Difference = ([Sales Max selected date] -[Sales Min selected date]) / [Sales Min selected date]
Now put everything in a matrix:
samratpbi_2-1710881493216.png

Now obviously column headers are not showing dates. Hence created 2 measures for max and min date and just place on top of max and min columns.

Max Selected Date = MAX(DatePoint[Sales Date])
Min Selected Date = MIN(DatePoint[Sales Date])
 
Hope this helps. If it resolves your problem then mark it as Solution, thanks

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

Here's my approach

  1. Create a Calendar Table
  2. Build a relationship (Many to One and Single) from the Date column of your Data Table to the Date column of your Calendar Table
  3. To your slicer, drag Date from the Calendar Table
  4. Write these measures

Sales = sum(Data[sale])

FD = min(Calendar[date])

LD = max(Calendar[date])

Sale on FD = calculate([Sales],datesbetween(Calendar[date],[FD],[FD]))

Sale on LD = calculate([Sales],datesbetween(Calendar[date],[LD],[LD]))

Change = [Sale on LD]-[Sale on FD]

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Here's my approach

  1. Create a Calendar Table
  2. Build a relationship (Many to One and Single) from the Date column of your Data Table to the Date column of your Calendar Table
  3. To your slicer, drag Date from the Calendar Table
  4. Write these measures

Sales = sum(Data[sale])

FD = min(Calendar[date])

LD = max(Calendar[date])

Sale on FD = calculate([Sales],datesbetween(Calendar[date],[FD],[FD]))

Sale on LD = calculate([Sales],datesbetween(Calendar[date],[LD],[LD]))

Change = [Sale on LD]-[Sale on FD]

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
samratpbi
Super User
Super User

Hi, what I have done is, created below sample data first.

samratpbi_0-1710881209839.png

Then created a slicer on date column.

samratpbi_1-1710881274158.png

Then created below measures:

Sales Max selected date =
CALCULATE(
    SUM(DatePoint[Sales]),
    DatePoint[Sales Date] = MAX((DatePoint[Sales Date]))
)
Sales Min selected date =
CALCULATE(
    SUM(DatePoint[Sales]),
    DatePoint[Sales Date] = MIN((DatePoint[Sales Date]))
)
above measures will give me values for max and min selected dates. If no dates selected, then max and min values from overall dates.
Now create a difference measure:
Sales Difference = ([Sales Max selected date] -[Sales Min selected date]) / [Sales Min selected date]
Now put everything in a matrix:
samratpbi_2-1710881493216.png

Now obviously column headers are not showing dates. Hence created 2 measures for max and min date and just place on top of max and min columns.

Max Selected Date = MAX(DatePoint[Sales Date])
Min Selected Date = MIN(DatePoint[Sales Date])
 
Hope this helps. If it resolves your problem then mark it as Solution, thanks

Thanks, the solution works. How did you get the column headers to show? I moved the measure Max Selected Date on top of the max column and it becomes a column and not the header. 

great to know it worked! you can create card visual and put max and min date into card visuals and put on top of respective column headers

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors