Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
This is an example of my dataset. I have values of everymonth since Jan-2017 to Dec-2019 with this shape.
I would like to use a chart line showing only YTD data.
Example:
I have a slicer where I select one specific month, if I choose that month, I want data from Jan. from that year to the selected month only. I choose May 2018, I only want to see data from Jan.2018 to May 2018 in my chart, how can I do that?
Thank yo for your time
Solved! Go to Solution.
First create a calendar table by going to Modelling->New Table and paste the following
(you must ensure that the newly created calendar table is not connected to the data table which you can do by checking the Model view)
Calendar =
var _fromYear=year(FIRSTDATE(DummyData[Date]))
var _toYear=year(LASTDATE(DummyData[Date]))
return
ADDCOLUMNS(
CALENDAR(
DATE(_fromYear,1,1),
DATE(_toYear,12,31)
),
"Start of Month",DATE( YEAR([Date]), MONTH([Date]), 1)
)
Next create a measure
SumValuesYTD =
VAR EndDate =
CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar' ) )
VAR EndDateYear =
YEAR ( EndDate )
VAR StartDate =
DATE ( EndDateYear, 1, 1 )
RETURN
CALCULATE (
SUM ( DummyData[Values] ),
FILTER ( DummyData, DummyData[Date] >= StartDate && DummyData[Date] < EndDate )
)
For the slicer use the "Calendar" "Start of Month" Field and for the visual (table/graph) use the Data Field (see screenshot below).
Let me know if this helps
First create a calendar table by going to Modelling->New Table and paste the following
(you must ensure that the newly created calendar table is not connected to the data table which you can do by checking the Model view)
Calendar =
var _fromYear=year(FIRSTDATE(DummyData[Date]))
var _toYear=year(LASTDATE(DummyData[Date]))
return
ADDCOLUMNS(
CALENDAR(
DATE(_fromYear,1,1),
DATE(_toYear,12,31)
),
"Start of Month",DATE( YEAR([Date]), MONTH([Date]), 1)
)
Next create a measure
SumValuesYTD =
VAR EndDate =
CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar' ) )
VAR EndDateYear =
YEAR ( EndDate )
VAR StartDate =
DATE ( EndDateYear, 1, 1 )
RETURN
CALCULATE (
SUM ( DummyData[Values] ),
FILTER ( DummyData, DummyData[Date] >= StartDate && DummyData[Date] < EndDate )
)
For the slicer use the "Calendar" "Start of Month" Field and for the visual (table/graph) use the Data Field (see screenshot below).
Let me know if this helps
Thank ou ver much for your time and solution. It works as expected!
I am using this slicer.
Which table is this Mes Seleccionado coming from, the same table as the data (fact table) or is there a seperate calendar table (dimension table) which it is from?
from the same table, the one I showed above in the first message. It all bellongs to it.
I want to use the fecha column (Date in English) and the mensual column that contains the values I want to display for the specific dates
@nachoroncero Are you able to create a new table (supporting calendar table) or a new column if the solution required it?
Yes, I could
@nachoroncero are you using a calendar table to select the month or just selecting it from the data table itself?
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 43 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |