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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
colacan
Resolver II
Resolver II

Showing Previous date in current row

 

Hi, I am trying to get previous date  in the current row. somehow it works without [Name] column but as soon as [Name] gets included, it shows blanks as below. I hope to someone explains the reason why. 
(The raw data is simple with name, date & price)

Thank you

 

colacan_1-1660045357477.png

 

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi  @colacan 

 

This is not just a problem with the [Nmae] column. If you add the [Price] column, you will get the same result, as shown below.

 

Please  note the part of the code circled in red.

 Picture1.png

 

When filter expressions are provided, the CALCULATETABLE function modifies the filter context to evaluate the expression. The CALCULATETABLE function used without filters achieves a specific requirement. It transitions row context to filter context.

 

For more information, please refer to:
CALCULATETABLE function (DAX) - DAX | Microsoft Docs 

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
v-yadongf-msft
Community Support
Community Support

Hi  @colacan 

 

This is not just a problem with the [Nmae] column. If you add the [Price] column, you will get the same result, as shown below.

 

Please  note the part of the code circled in red.

 Picture1.png

 

When filter expressions are provided, the CALCULATETABLE function modifies the filter context to evaluate the expression. The CALCULATETABLE function used without filters achieves a specific requirement. It transitions row context to filter context.

 

For more information, please refer to:
CALCULATETABLE function (DAX) - DAX | Microsoft Docs 

 

Best regards,

Yadong Fang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

colacan
Resolver II
Resolver II

(지환 후배님 반갑습니다.  전 통계92입니다.)

Unfortunately, I am not looking for the solution using FILTER(all(table), ... or FILTER(all(table[date]), due to the permermance issue. I am still looking for the REASON why above error of making the [prevdate] blank when the Name column gets included. it must be context problem which I can't figure out.  Thanks.

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please try the below measure.

The reason is,

inside calculatetable DAX function, your measure only removes TestTable[Date] column.

I think TestTable[Name] column also has to be removed.

 

 

Prevdate =
VAR currentdate =
    MAX ( TestTable[Date] )
VAR prevdate =
    MAXX (
        CALCULATETABLE (
            TestTable,
            FILTER ( ALL ( TestTable ), TestTable[Date] < currentdate )
        ),
        TestTable[Date]
    )
RETURN
    prevdate

 


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.