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

How to compare values for two specific dates

I want to compare values between last date and second last date. The date table has future dates as well so I am filtering the date with the non null FactCovidADCDaily[Daily Census (Total)] value. Here is my DAX:

 

Second Last Date =
CALCULATE (
MAX ( DimDate[Date] ),
FILTER ( DimDate, 'DimDate'[Date] <> MAX ( DimDate[Date] )),
FILTER(FactCovidADCDaily, FactCovidADCDaily[Daily Census (Total)] <> BLANK() ))
 
Last Date =
CALCULATE (
MAX ( DimDate[Date] ),
FILTER(FactCovidADCDaily, FactCovidADCDaily[Daily Census (Total)] <> BLANK() ))
 
Problem 1 : I don't know why but both "Last Date" and "Second Last Date" is displaying the same result. Am I doing anything wrong?
 
Problem 2 : Can you please provide me a DAX for -
                    If FactCovidADCDaily[Daily Census (Total)] on Second Last Date > Last Date then 1 else 0
1 REPLY 1
MFelix
Super User
Super User

Hi @Anonymous ,

 

On the second last date you are picking up all the dates except the max date however since you are getting the full values of the table you always get the same values.

 

I don't know how you have your information but  the second last date can be picked up with something similar to:

Second Last Date = 
MAXX (
    FILTER (
        ALLSELECTED(FactCovidADCDaily);
        FactCovidADCDaily[Daily Census (Total)] <> BLANK ()
            && FactCovidADCDAily[Date] < MAX ( DimDate[Date] )
    );FactCovidADCDaily[Date]

)

 

 


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



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.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.