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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Shliim_1
Frequent Visitor

Shift dates based on slicer

Hi, 

 

I need a pretty difficult DAX command which I can't figure out. 

 

End-goal: I need to compare customer journies of our clients . Therefore I need/want to overlap the journies over each other.

How I imagine it:

  1. the user selects a product or region using a slicer which applies it on a table called "client-data"
    1. the user shouldn't be able to filter on a client but a product or region. on which the user likes to zoom in.
    2. the "client-data" table is uncoupeled from the "Master" table because one client has multiple lines with different products or regions which all need to be taken into account. 
  2. The halfwaypoint (End_date - Start_date)/2 of the selected product of each client needs to used to shift the whole dataset of the client. 
  3. if the selected product is repeated in use by a client, choose the first one.  

visually -> 

Shliim_1_0-1708332426321.png

clienttable:

RegionPRODUCTClientNr
1PR_1CL_1
1PR_2CL_1
2PR_3CL_2
2PR_2CL_2
3PR_1CL_3
3PR_3CL_3

 

MasterTable

 

CLIENTSTARTDATEENDDATEPRODUCT...>
CL_1DATE 1DATE2 PRODUCT1 ..>
CL_2.............>
..............
     

 

1 REPLY 1
123abc
Community Champion
Community Champion

To achieve the described functionality, you'll need to create a calculated column or measure in Power BI that calculates the halfway point for each client based on the selected product or region. Here's a breakdown of the steps:

  1. Identify the Selected Product/Region: You need to identify the selected product or region using a slicer. This will be used to filter the data.

  2. Calculate Halfway Point for Each Client's Journey: Determine the halfway point between the start date and end date for the selected product or region of each client. This will be the shifting point for each client's journey.

  3. Shift the Dataset: Shift the dataset for each client based on the calculated halfway point.

Here's how you can implement this in DAX:

 

 

ShiftedStartDate =
VAR SelectedProductOrRegion = SELECTEDVALUE('client-data'[PRODUCT])
VAR ClientID = 'client-data'[ClientNr]
VAR HalfwayPoint =
CALCULATE (
MIN('client-data'[STARTDATE]) +
(MIN('client-data'[ENDDATE]) - MIN('client-data'[STARTDATE])) / 2,
FILTER('client-data', 'client-data'[PRODUCT] = SelectedProductOrRegion),
FILTER('client-data', 'client-data'[ClientNr] = ClientID)
)
RETURN
'client-data'[STARTDATE] + HalfwayPoint - CALCULATE(MIN('client-data'[STARTDATE]), 'client-data'[ClientNr] = ClientID)

 

 

This DAX formula assumes that 'client-data' is your client table, and you have columns like [ClientNr], [STARTDATE], [ENDDATE], and [PRODUCT]. Replace these with your actual column names.

  • The SELECTEDVALUE function gets the selected product or region from the slicer.
  • The CALCULATE function calculates the halfway point for the selected product or region for each client.
  • The FILTER function filters the data to calculate the halfway point for each client.
  • The RETURN statement returns the shifted start date based on the halfway point.

You can create a calculated column or measure using this DAX formula, depending on your requirement. Adjust the formula according to your data model and relationships.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.