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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Get Previous month's previous day

Good day,

 

I am currently working on a Day-on-Day comparison. I would like to create the following calculations:

1. Latest day of the current month Sales

2. Previous day of the current month Sales

3. Latest day of previous month Sales

4. Previous day of the previous month Sales

 

Your assistance is highly appreciated.

 

Kind Regards,

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

(1)You can use PREVIOUSDAY dax to calculate the sale for pervious day .

previous sales = CALCULATE(MAX('Table'[Sales]),PREVIOUSDAY('Table'[Date]))

(2)The latest day sale for current month

current month latest sales = CALCULATE(MAX('Table'[Sales]),FILTER('Table',max('Table'[Date])<=TODAY()))

(3)The latest day sale for previous month

previous month latest sales = CALCULATE(MAX('Table'[Sales]),FILTER('Table','Table'[Date]<=EOMONTH(TODAY(),-1)))

The final result is as shown :

Ailsa-msft_0-1622790841035.png

I have attached my pbix file ,you can refer to it .

 

Best Regards

Community Support Team _ Ailsa Tao

 

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

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous 

(1)You can use PREVIOUSDAY dax to calculate the sale for pervious day .

previous sales = CALCULATE(MAX('Table'[Sales]),PREVIOUSDAY('Table'[Date]))

(2)The latest day sale for current month

current month latest sales = CALCULATE(MAX('Table'[Sales]),FILTER('Table',max('Table'[Date])<=TODAY()))

(3)The latest day sale for previous month

previous month latest sales = CALCULATE(MAX('Table'[Sales]),FILTER('Table','Table'[Date]<=EOMONTH(TODAY(),-1)))

The final result is as shown :

Ailsa-msft_0-1622790841035.png

I have attached my pbix file ,you can refer to it .

 

Best Regards

Community Support Team _ Ailsa Tao

 

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

selimovd
Super User
Super User

Hey @Anonymous ,

 

you can get the dates:

1. With the function EOMONTH

2. Take the value from 1. and do -1

3. Use EOMONTH for the PREVIOUSMONTH

4. Take the day from 3. and do -1

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
Anonymous
Not applicable

Hi @selimovd I am relatively new on Power Bi so scripting is not that good...do you mind writing out the actual syntax?

 

Thanks 

Hey @Anonymous ,

 

sure, I can help you. But then I need more information.

Do you want these dates as a calculated column or as a measure? And what do you want to do with this date? For example if you want to use it as a slicer you need it as a column, etc.

 

Best regards

Denis

Anonymous
Not applicable

Hi @selimovd ,

 

I need them as measures. I managed to create measure for the current month. The issue is on the previous month last day and previous months previous date. Please see screenshot below and the syntax used.

SaneleZwane_0-1622640638261.png

Sales'[Transaction Date]=max('Daily Funeral Cover Sales'[Transaction Date])-1))

Hey @Anonymous ,

 

try the following measures:

For 1:

Latest day of the current month Sales = 
VAR vCurrentDate = MAX( 'Daily Funeral Cover Sales'[Transaction Date] )
RETURN
    CALCULATE(
        MAX( 'Daily Funeral Cover Sales'[Transaction Date] ),
        YEAR( vCurrentDate ) = YEAR( 'Daily Funeral Cover Sales'[Transaction Date] ) && MONTH( vCurrentDate ) = MONTH( 'Daily Funeral Cover Sales'[Transaction Date] )
    )

 

For 2:

Previous day of the current month Sales = [Latest day of the current month Sales] - 1

 

For 3:

Latest day of previous month Sales = 
VAR vCurrentDate = EOMONTH( MAX( 'Daily Funeral Cover Sales'[Transaction Date] ), -1)
RETURN
    CALCULATE(
        MAX( 'Daily Funeral Cover Sales'[Transaction Date] ),
        YEAR( vCurrentDate ) = YEAR( 'Daily Funeral Cover Sales'[Transaction Date] ) && MONTH( vCurrentDate ) = MONTH( 'Daily Funeral Cover Sales'[Transaction Date] )
    )

 

And your number 4:

Previous day of the previous month Sales = [Latest day of previous month Sales] - 1

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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