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
jdw_msft
Frequent Visitor

Getting data from previous day/yesterday's date

 

Hello everyone, i have sample table like this picture:

I'll describe the table columns:

  1. date_for_visual : Date will be used in visual (slicer etc.)
  2. actual_date: actual date's data
  3. sales_demand: monthly sales goal
  4. fulfilled_sales: actual month's sales
  5. fulfilled_order: percentage from (fulfilled_sales/sales_demand)

I've had a problem and it makes me stuck, i just want to show data from previous month whenever the month is changed (when the current month and date is February 1st, i want to show data from yesterday/last day of the month), is there any way to show it?

 

P.S. : I used date_for_visual for the slicer 

 

 

The sample dataThe sample data

 

 

Table realationshipTable realationship

 

 

 

Using actual_dateUsing actual_date

 

Current conditionCurrent condition

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

In the below sample, I tried to create last non blank value for fulfilled sales.

 

Jihwan_Kim_1-1726026343601.png

 

 

Jihwan_Kim_0-1726026320949.png

 

Last Non Blank fulfilled sales Value: = 
VAR _SelectedDate =
    MAX ( 'calendar'[Date] )
VAR _lastnonblankdate =
    MAXX (
        FILTER (
            ADDCOLUMNS (
                FILTER (
                    ALL('calendar'[Date]),
                    'calendar'[Date] <= _SelectedDate
                ),
                "@metrics", CALCULATE ( SUM ( sales[fulfilled_sales] ) )
            ),
            NOT [@metrics] == BLANK ()
        ),
        'calendar'[Date]
    )
RETURN
    CALCULATE (
        SUM ( sales[fulfilled_sales] ),
        REMOVEFILTERS ( 'calendar' ),
        'calendar'[Date] = _lastnonblankdate
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

In the below sample, I tried to create last non blank value for fulfilled sales.

 

Jihwan_Kim_1-1726026343601.png

 

 

Jihwan_Kim_0-1726026320949.png

 

Last Non Blank fulfilled sales Value: = 
VAR _SelectedDate =
    MAX ( 'calendar'[Date] )
VAR _lastnonblankdate =
    MAXX (
        FILTER (
            ADDCOLUMNS (
                FILTER (
                    ALL('calendar'[Date]),
                    'calendar'[Date] <= _SelectedDate
                ),
                "@metrics", CALCULATE ( SUM ( sales[fulfilled_sales] ) )
            ),
            NOT [@metrics] == BLANK ()
        ),
        'calendar'[Date]
    )
RETURN
    CALCULATE (
        SUM ( sales[fulfilled_sales] ),
        REMOVEFILTERS ( 'calendar' ),
        'calendar'[Date] = _lastnonblankdate
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.