This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi PBI Community,
I'm stuck with the following issue.
I have a table in Power BI displaying values as shown below.
In Power BI, I want to create a YTD measure that sums the values of the Current_Month column based on the selected month.
For example, if the user selects Year = 2025 and MonthName = February, the measure should sum the values from January till February.
While using MonthNumber in the slicer it works correctly, using MonthName only filters data for the selected month instead of calculating the YTD sum.
can someone help me to get YTD value if monhname is put in the slicer.
Below is my measure
looking forward to hear from community
Solved! Go to Solution.
Hi @Zaheer21,
Try sorting the Month_Name column by Month_Number in the dataset to ensure correct chronological order.
Updated YTD Measure:
YTD_Current_Month =
VAR SelectedYear = SELECTEDVALUE(Bassria[Year])
VAR SelectedMonthName = SELECTEDVALUE(Bassria[Month_Name])
VAR SelectedMonthNumber =
CALCULATE(
MAX(Bassria[Month_Number]),
Bassria[Month_Name] = SelectedMonthName
)
RETURN
CALCULATE(
SUM(Bassria[Current_Month]),
Bassria[Category] = "Actual",
Bassria[Year] = SelectedYear,
Bassria[Month_Number] <= SelectedMonthNumber,
ALL(Bassria[Month_Name]) -- Ensures we don't filter out earlier months
)
I have attached the updated .pbix file for reference.
If this response was helpful, please accept it as a solution and give kudos to support other community members.
Hi @Zaheer21,
Try sorting the Month_Name column by Month_Number in the dataset to ensure correct chronological order.
Updated YTD Measure:
YTD_Current_Month =
VAR SelectedYear = SELECTEDVALUE(Bassria[Year])
VAR SelectedMonthName = SELECTEDVALUE(Bassria[Month_Name])
VAR SelectedMonthNumber =
CALCULATE(
MAX(Bassria[Month_Number]),
Bassria[Month_Name] = SelectedMonthName
)
RETURN
CALCULATE(
SUM(Bassria[Current_Month]),
Bassria[Category] = "Actual",
Bassria[Year] = SelectedYear,
Bassria[Month_Number] <= SelectedMonthNumber,
ALL(Bassria[Month_Name]) -- Ensures we don't filter out earlier months
)
I have attached the updated .pbix file for reference.
If this response was helpful, please accept it as a solution and give kudos to support other community members.
Hi,
Try this approach
Total = sum(Data[Sales])
Total YTD = calculate([total],datesytd(calendar[date])
Hope this helps.
@Zaheer21 , Try using
DAX
YTD_Current_Month =
VAR SelectedYear = SELECTEDVALUE(Bassria[Year])
VAR SelectedMonthName = SELECTEDVALUE(Bassria[Month_Name])
VAR SelectedMonthNumber =
CALCULATE(
MAX(Bassria[Month_Number]),
Bassria[Month_Name] = SelectedMonthName
)
RETURN
CALCULATE(
SUM(Bassria[Current_Month]),
Bassria[Category] = "Actual" &&
Bassria[Year] = SelectedYear &&
Bassria[Month_Number] <= SelectedMonthNumber
)
Proud to be a Super User! |
|
@bhanu_gautam I have tried but it's not working, it's returning 133 instead of 166.
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 39 | |
| 28 | |
| 27 | |
| 22 | |
| 18 |
| User | Count |
|---|---|
| 67 | |
| 37 | |
| 32 | |
| 26 | |
| 25 |