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!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi Power BI Experts,
Scenario: I have date column, amount column and user want to see the sum of data of 2024 (Jan 2024 to currentmonth) when I select the June 2024 then the data should sum the between Jan 2024 to June 2024, similarly, If I select May 2024 then the data should sum up between Jan 2024 to May 2024. Similarly, If I select July 2023 then the data should sum up between Jan 2023 to Dec 2023.
Can anyone help on this issue?
Best Regards,
Power BI
Solved! Go to Solution.
@Powers , First create a date table
DateTable =
ADDCOLUMNS (
CALENDAR (DATE(2023, 1, 1), DATE(2024, 12, 31)),
"Year", YEAR([Date]),
"Month", FORMAT([Date], "MMM YYYY"),
"MonthNumber", MONTH([Date])
)
Make sure your Sales table is related to the DateTable on the Date column.
DAX
Amount =
VAR __SelectedMonth = MAX(DateTable[Date])
VAR __StartDate = DATE(YEAR(__SelectedMonth), 1, 1)
VAR __EndDate = EOMONTH(__SelectedMonth, 0)
RETURN
CALCULATE(
SUM(Sales[Amount]),
FILTER(
ALL(DateTable),
DateTable[Date] >= __StartDate && DateTable[Date] <= __EndDate
)
)
Add a slicer to your report using the Month column from the DateTable
Proud to be a Super User! |
|
@Powers , First create a date table
DateTable =
ADDCOLUMNS (
CALENDAR (DATE(2023, 1, 1), DATE(2024, 12, 31)),
"Year", YEAR([Date]),
"Month", FORMAT([Date], "MMM YYYY"),
"MonthNumber", MONTH([Date])
)
Make sure your Sales table is related to the DateTable on the Date column.
DAX
Amount =
VAR __SelectedMonth = MAX(DateTable[Date])
VAR __StartDate = DATE(YEAR(__SelectedMonth), 1, 1)
VAR __EndDate = EOMONTH(__SelectedMonth, 0)
RETURN
CALCULATE(
SUM(Sales[Amount]),
FILTER(
ALL(DateTable),
DateTable[Date] >= __StartDate && DateTable[Date] <= __EndDate
)
)
Add a slicer to your report using the Month column from the DateTable
Proud to be a Super User! |
|