PowerBI - selecting dynamic column based on slicer selection

Bobstar

New Member
Joined
Oct 7, 2020
Messages
20
Office Version
  1. 2019
Platform
  1. Windows
Hi

I’m looking for helping writing a measure that selects a dynamic column based on slicer selection.

I have a large data set on power query that has hundreds of columns. I’m creating a dashboard where one of the slicers will be ‘dates’ allowing user to enter a from (start date) and to (end date). This would then filter the main data set and produce a subset data based on the user’s selection. A new column will then calculate percentage return ((end date/start date – 1)*100) over that period.

For visualization, this is how the data should look like

Main data

Portfolio31/07/202001/08/202002/08/202003/08/202004/08/202005/08/2020
P1100.0100.5101.0101.5102.0102.5
P2100.0101.0102.0103.0104.0105.0
P3100.0105.0110.0115.0120.0125.0

If user selects start date as 02/08/2020 and end date as 04/08/2020, a subset table will be generated as follows. The first column ("Portfolio") will be static but the two columns with dates will be dynamic based on user selection.

Portfolio02/08/202004/08/2020Return (%)
P1101.0102.01.0
P2102.0104.02.0
P3110.0120.09.0

I would really appreciate your help in writing a measure that can do the above.

Thanks

B
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
First, unpivot the date columns so you have portfolio, date, value. The rest is covered in my video here
 
Upvote 0
Solution
First, unpivot the date columns so you have portfolio, date, value. The rest is covered in my video here
Thanks Matt. The video is very helpful. I shall give it a go using instructions from your video.
 
Upvote 0
First, unpivot the date columns so you have portfolio, date, value. The rest is covered in my video here
Hi Matt. Your solution works very well, thanks.
I had the following follow up questions and I would appreciate your help:
  1. The source data will be refreshed daily. Do I need to prepare it as unpivoted table?
  2. Is there a way to set the date slicers such that a user cannot input a ‘To’ date (comparison calendar) earlier than 'From' date?
  3. Is there a way to set the slicers such that within a slicer, a user cannot select multiple dates
Once again, thanks for your help.
 
Upvote 0
Hi Matt. Your solution works very well, thanks.
I had the following follow up questions and I would appreciate your help:
  1. The source data will be refreshed daily. Do I need to prepare it as unpivoted table?
  2. Is there a way to set the date slicers such that a user cannot input a ‘To’ date (comparison calendar) earlier than 'From' date?
  3. Is there a way to set the slicers such that within a slicer, a user cannot select multiple dates
Once again, thanks for your help.
The marked solution post has been switched accordingly.

@Bobstar - please create another thread for your new question(s).
 
Upvote 0

Forum statistics

Threads
1,215,104
Messages
6,123,113
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top