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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.


Go to My LinkedIn Page


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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