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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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