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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jj_0511
Helper I
Helper I

show sales by date for month-to-date dates

Hello:

I have a Date table and Sales table linked via 'Date'[Date] --> 'Sales'[Order date].

There's a slicer on 'Date'[Date]. When a date is selected in slicer, I want to show sales by date for Month-to_date for selected date.

 

For example, if May-3-2023 is selected, the following result is shown:

 

Date                 Sales

May-1-2023      100

May-2-2023      200

May-3-2023      300

 

if May-10-2023 is selected, the following result is shown:

 

Date                 Sales

May-1-2023      100

May-2-2023      200

May-3-2023      300

...     ...

May-9-2023    200

May-10-2023  100

 

How to achieve this in Power BI?

Thanks.

 

1 ACCEPTED SOLUTION

Great, @Ahmedx , that helped me to get I solution I need. Thanks!

View solution in original post

6 REPLIES 6
Ahmedx
Super User
Super User

you need to create two date tables
one for the slicer and one for filtering sales tables

 

=
VAR _selectDate = MAX('Date1'[date])
VAR _Startmonth = EOMONTH(_selectDate,-1)+1
RETURN
CALCULATE (SUM('Table'[Sales]), KEEPFILTERS(Filter(ALL('Date2'), 'Date2'[date] >= _Startmonth && 'Date2'[date]<=_selectDate)))

 

@Ahmedx thanks, but I still have trouble understanding your solution, Would you mind creating a pbix? 

pls try this

Sample PBIX file attached

show sales by date for month-to-date dates.pbix

Great, @Ahmedx , that helped me to get I solution I need. Thanks!

Ahmedx
Super User
Super User

First you need to remove the relationship between the date table and the sales table
then write like this

=
VAR _selectDate = MAX('Date'[date])
VAR _Startmonth = EOMONTH(_selectDate,-1)+1
RETURN
CALCULATE (SUM('Table'[Sales]), Filter(ALL('table'), 'table'[date] >= _Startmonth && 'table'[date]<=_selectDate))

Your calculation only gives a scalar value of Month-to-selected date sales

but I need a table showing sales by date from start of month up to selected date:

Date                 Sales

May-1-2023      100

May-2-2023      200

May-3-2023      300

...     ...

May-9-2023    200

May-10-2023  100

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.