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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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