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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Measure to retrieve the value on last day of previous month

Hello, 

 

I am trying to create a measure to return the value on the last day of the previous month but don't seem to be successful. 

My dataset has values for each day, but I am only interested in the value (not sum) at the end of month. 

 

I have tried this:

 

Measure 300 = CALCULATE([Total EOD Balance in GBP],
             LASTDATE(PREVIOUSMONTH('Value Date'[Date]))
             )
 
 
Thank you. 
 
Soo
1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, here's my solution.

Modify the formula to:

 

Measure 300 =
CALCULATE (
    [Total EOD Balance in GBP],
    FILTER (
        ALL ( 'Value Date' ),
        'Value Date'[Date] = EOMONTH ( MAX ( 'Value Date'[Date] ), -1 )
    )
)

 

I create a sample and get the correct result.

vkalyjmsft_0-1662625464952.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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

4 REPLIES 4
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, here's my solution.

Modify the formula to:

 

Measure 300 =
CALCULATE (
    [Total EOD Balance in GBP],
    FILTER (
        ALL ( 'Value Date' ),
        'Value Date'[Date] = EOMONTH ( MAX ( 'Value Date'[Date] ), -1 )
    )
)

 

I create a sample and get the correct result.

vkalyjmsft_0-1662625464952.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yanjiang-msft you also helped me! Thanks so much!

CNENFRNL
Community Champion
Community Champion

CNENFRNL_1-1662380921004.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

speedramps
Super User
Super User

Hi

 

Click here to download a solution 

 

How it works.

 

Firstly, please do all these free training modules to lcearn about calendar tables and monthly offset

Calendar Table training

 

This dax measure gets the calendar offset to get the last date of the previous month.

Then uses FILTER to create a subset for that date.

Then uses CALCULATE to get the balance for that subset.

 

Balance end of previous period =
VAR last_date_of_previous_period = CALCULATE( MAX('Calendar'[Date]), 'Calendar'[Month offset] = -1)
VAR mysubset = FILTER('Calendar', 'Calendar'[Date] = last_date_of_previous_period)
RETURN
CALCULATE(
    SELECTEDVALUE(Balance[Balance]),
    mysubset)
 

Thanks for reaching out for help.

I put in a lot of effort to help you, now please quickly help me by giving kudos.

Remeber we are unpaid volunteers and here to coach you with Power BI and DAX skills and techniques, not do the users job for them. So please click the thumbs up and accept as solution button. 

If you give someone a fish then you only give them one meal, but if you teach them how to fish then they can feed themselves and teach others for a lifetime.  I prefer to teach members on this forum techniques rather give full solutions and do their job. You can then adapt the technique for your solution, learn some DAX skills for next time and soon become a Power BI Super User like me. 

One question per ticket please. If you need to extend your request then please raise a new ticket.

You will get a quicker response and each volunteer solver will get the kudos they deserve. Thank you ! 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors