Do you need to get the date value from the date slicer and display it in a calculated column in Power BI? It’s actually not as complicated as you think.
In this article, I will go through a step-by-step approach to getting date values from a date slicer with just a simple formula.
Read to learn more.
Introduction
To get started, open your Power BI Desktop and go to the page of your report that contains the date value.
Here is what mine looks like. I’m using the Sample Superstore dataset which you download on the datasets page.
Don’t forget that what we want to do is to get the date value from a date slicer.
Create the Slicer
The first thing to do is to create the slicer, and to do that, go to the Visualizations pane in the home tab and select slicer (that is the slicer on the screen below).
Now, add your date to the slicer (drag it from the Fields pane into the slicer field just below the Visualizations pane).
You will notice a change in the slicer, indicating a newly-added value. You can adjust the slicer to choose a timeframe, and doing this reflects the total value.
For example, the total revenue for the total date (1/1/2014 – 12/31/2018) is 2,297,200.86.
However, if I change drag the slicer, there will be a change in the total value (as displayed below). The total value has changed to 1,783,379.14.
You can drag the slicer to match the exact date you want and the value will change in the calculated column.
To do that, you will have to create a new measure. And to create a new measure, make sure you are on the home tab and click on New Measure.
You will see a new box where you will input the formula to create your measure.
Now, it’s time to create your measure by inputting the formula. (Delete the content in the measure box).
Input the Formula
Now it’s time to input the formula to create a new measure.
Latest Date = (LASTDATE('Calendar'[Date]))
- Latest Date = The name of the measure created
- LASTDATE = A function that makes us input the date value
- ‘Calendar’ = Where I have the date value
- [Date] = The date value itself
After inputting the formula, press the tick button and the new measure will be created and added to the Fields pane. It’s saved under the Calendar field in my Power BI. Could be different in yours.
Now, on the Visualizations pane, select Card and it will show on your canvas. After that, drag the new measure created Latest Date to the Fields pane under the Visualizations pane.
This automatically shows you the latest date as you adjust your slicer, and in turn, has an effect on the Total value.
Conclusion: How to Get Date Value From a Date Slicer in Power BI
Now, that is how to get the date value from a date slicer in Power BI Desktop.
Thanks for reading.