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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
davidlittle
Frequent Visitor

Get a previous month date in the context of a table visualisation

Hi, I have spent best part of a week trying to get this to work and it should be so simple so I know im doing something wrong. I have a table of orders that is taken as a snapshot from a live DB every day. I am using a table visualisation to filter to show just the snapshots on the first of every month. I then perform a count of all orders on that day that were "not in process" (Green box). I then want to "lookup" to what that figure was on the first day of the previous month. I have tried lots of eays of doing it using "EARLIER()", "FIRSTDATE(PREVIOUSMONTH())" and various incarnations of ALL() and ALLSELECTED(). And i cannot get it to work. My current incarnation allows me to specify a date manually and set all fields in the column to a previous month, but all the same previous month .. i want the previous month of each row... NB the Dates table is related only on "Snapshot Date"

 

davidlittle_0-1623878215451.png

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

I'd expect something like this to be what you're after:

 

OutstandingLM =
VAR CurrDate = SELECTEDVALUE ( Dates[Date] )
VAR PriorDate = EOMONTH ( CurrDate, -2 ) + 1
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Orders Snapshot'[Order No] ),
        Dates[Date] = PriorDate
    )

 

View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

I'd expect something like this to be what you're after:

 

OutstandingLM =
VAR CurrDate = SELECTEDVALUE ( Dates[Date] )
VAR PriorDate = EOMONTH ( CurrDate, -2 ) + 1
RETURN
    CALCULATE (
        DISTINCTCOUNT ( 'Orders Snapshot'[Order No] ),
        Dates[Date] = PriorDate
    )

 

You sir, are a god. I modified it slightly to be -2 in the EOMONTH func as otherwise it returned the same day, but it works! thank you!!

Yep. I already edited that after thinking about it more carefully.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors