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
Anonymous
Not applicable

Power BI DAX for CALCULATETABLE with FILTER ON PREVIOUSDAY

Good day,

 

I do have below scenario (example)

 

I would like track ONLY changes compare to prior day (BusinessDate). 

 

Customer Table

CustomerNameCustomerId
A1
B2
C3

 

Review Table

CustomerIdBusinessDate  ReviewDate
116-Jun-1924-Jan-18
117-Jun-1925-Jan-19
216-Jun-1919-May-18
217-Jun-1919-May-18
316-Jun-1922-Feb-18
317-Jun-1922-Feb-18

 

For CustomerId = 1, the ReviewDate has changed on the BusinessDate 17-Jun-2019 from 24-Jan-2018 to 25-Jan-2019.  And the rest of the customers information have not changed. So, it should show " 1 '.

When user selects the date (17-Jun-2019) from the Date slicer, Table / visual should only show " 1 ".

When user selects the date 16-Jun-2019 from the Date slicer, it should show " 0 " since the information has not changed.

 

Please note: I have used CALCULATETABLE(ReviewTable, FILTER(Calendar, Date = PREVIOUSDAY(Businessday))

 to store previous day information to compare, but didn't work. 

I do not understand why PREVIOUSDAY hasn't worked in that case.

 

Thank you

3 REPLIES 3
MFelix
Super User
Super User

Hi @Anonymous ,

 

Not sure if this is still needed but try adding a calendar table (no related with other tables) and the following 3 measures to your data model.

 

 

Check_Value =
VAR Minimum_Date =
    CALCULATE ( MIN ( Review[BusinessDate  ] ); ALL ( Review ) )
VAR Selected_Date =
    MAX ( 'Calendar'[Date] )
VAR Customer_Selection =
    SELECTEDVALUE ( Review[CustomerId] )
RETURN
    IF (
        Selected_Date = Minimum_Date;
        0;
        IF (
            MINX (
                FILTER (
                    ALL ( Review );
                    Review[BusinessDate  ] = Selected_Date - 1
                        && Review[CustomerId] = Customer_Selection
                );
                Review[ReviewDate]
            )
                <> MAX ( Review[ReviewDate] )
                = TRUE ();
            1;
            0
        )
    )

Validation_Date = IF(MAX(Review[BusinessDate  ]) = SELECTEDVALUE('Calendar'[Date]); 1 ; 0)

Count Changes = 
SUMX(FILTER(Review;[Validation_Date] = 1);[Check_Value])

 

Now use your count changes has your calculation please check the result in PBIX file attach.

 

As you can see you can even place it on a bar chart.

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



v-lili6-msft
Community Support
Community Support

hi, @Anonymous 

First, you must know that calculated column and calculate table can't be affected by any slicer. 
Notice:
1. Calculation column/table not support dynamic changed based on filter or slicer.
2. Only measure can be affected by filter/slicer, so you can use it to get dynamic summary result.

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you for the reply.

 

Ok. I would like to find out how many ReviewDates have changed Today when comparing with Yesterday's ReviewDate.

I am looking for suitable DAX.

 

Thanks

 

 

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.