Forum Discussion
YTD Measure using Month Name Slicer
- 1 year ago
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.
Thanks ArwaAldoud
It's Working fine now.