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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Zaheer21
Frequent Visitor

YTD Measure using Month Name Slicer

Hi PBI Community,

I'm stuck with the following issue.

I have a table in Power BI displaying values as shown below.

Zaheer21_0-1741863372357.png

 

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.



Zaheer21_1-1741863785087.png

Zaheer21_2-1741863854232.png

 

Below is my measure 

YTD_Current_Month =
VAR SelectedYear = SELECTEDVALUE(Bassria[Year])
VAR SelectedMonth = MAX(Bassria[Month_Number])

RETURN
CALCULATE(
    SUM(Bassria[Current_Month]),
        Bassria[Category] = "Actual" &&
        Bassria[Year] = SelectedYear &&
        Bassria[Month_Number] <= SelectedMonth
)


looking forward to hear from community

1 ACCEPTED SOLUTION
ArwaAldoud
Super User
Super User

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
)

ArwaAldoud_0-1742005347252.png

 

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. 

 

View solution in original post

5 REPLIES 5
ArwaAldoud
Super User
Super User

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
)

ArwaAldoud_0-1742005347252.png

 

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. 

 

Thanks @ArwaAldoud 

It's Working fine now.

Ashish_Mathur
Super User
Super User

Hi,

Try this approach

  1. Created a calculated column (Date) formula = 1*("1/"&Data[Month_number]&"/"&Data[Year])
  2. Create a Calendar table with calculated column formulas for Year, Month name and Month number.  Sort the Month name column by the Month number
  3. Create a relationship (Many to One and Singe) from the Date column of the Fact table to the date column of the Calendar table
  4. To your visual/slicer/filter, dray Year and Month name from the Calendar table and select a month/year
  5. Write these measures

Total = sum(Data[Sales])

Total YTD = calculate([total],datesytd(calendar[date])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
bhanu_gautam
Super User
Super User

@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
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






@bhanu_gautam I have tried but it's not working, it's returning 133 instead of 166.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.