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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
johankent30
Helper I
Helper I

DAX Variable Date Column

I am trying to create a column in power bi that will change based on a slicer selection. For example, let's say that I have the table below:

Date     |    Column A     |    Column B
1/1/2019         5                 6

I want to be able to create a column (or measure) that will store the value by row of Date+ColumnA or ColumnB based on a slicer. So if I have a slicer that has "Column A" selected, there would be a column (Column C) that would have 1/6/2019 (Date+Column A)

Does anyone have any ideas for how to do this?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@johankent30  - 

One possibility:

1. Store the Date +A as one Calculated Column, Date +B as s second Calculated column

2.  Create a disconnected Parameters table, with column Add Type.

3.  Create a measure like this: (You could do the date math in the measure, but I find it cleaner to do it this way and it may improve performance.)

 

Date Picker = 
IF(
	SELECTEDVALUE('Parameters'[Add Type]) = "A",
	MAX(<yourtable>[DateA]),
	MAX(<yourtable>[DateB])
)

View solution in original post

1 REPLY 1
Anonymous
Not applicable

@johankent30  - 

One possibility:

1. Store the Date +A as one Calculated Column, Date +B as s second Calculated column

2.  Create a disconnected Parameters table, with column Add Type.

3.  Create a measure like this: (You could do the date math in the measure, but I find it cleaner to do it this way and it may improve performance.)

 

Date Picker = 
IF(
	SELECTEDVALUE('Parameters'[Add Type]) = "A",
	MAX(<yourtable>[DateA]),
	MAX(<yourtable>[DateB])
)

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.