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

Create a matrix in powerbi

Hello, 

 

My data is at day level and I would like to create a table using DAX measures that retrieve the value (not the sum of the month) at the last day of the previous month and the month before that. So for now the table should look like this:

I would also like to calculate the difference between these two values. 

 

soochoilondon_0-1662289436103.png

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous So like this?

Measure =
  VAR __LastMonthDate = EOMONTH(TODAY(),-1)
  VAR __Last2MonthDate = EOMONTH(TODAY(),-2)
  VAR __LastMonth = MAXX(FILTER('Table',[Date]=__LastMonthDate),[Value])
  VAR __Last2Month = MAXX(FILTER('Table',[Date]=__Last2MonthDate),[Value])
RETURN
  __LastMonth - __Last2Month


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hello, 

 

I have a dataset, linked to a data table. The dataset has values on a daily basis.

 

We are interested in finding the difference between the value at the end of last month and yesterday's value.

 

The table will update tomorrow so that the most recent column has values for 3rd September etc but the calculations will remain the same just that 3rd SEPT will then be yesterday's value.

 

I would like to display these two figures on a card visual. 

 

soochoilondon_0-1662234936905.png

 

The values in the table are from a MEASURE:

 

Total EOD Balance in GBP =
SUMX('V3 Data',
    'V3 Data'[EOD_Balance] /
         LOOKUPVALUE('Daily FX Rate'[Value],
         'Daily FX Rate'[Date], 'V3 Data'[Month and Year],
         'Daily FX Rate'[Currency], 'V3 Data'[Currency] ))
 
Thank you! 
Soo

 

 

Hi

 

Click here to download a solution 

 

How it works

 

Firstly please do all these free training module to learn abou calendat tables and offsets.

Calendar Table training

 

You will then know how to use a Month offset to get the previous month

and the day offset to get the previous day. Then build the rest of the report youself.

 

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 ! 

 

Yesterday's balance =
CALCULATE(
    SELECTEDVALUE(Balance[Balance]),
    'Calendar'[Day offset] = -1)
 
End of last month balance =
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)
 
Difference =
[End of last month balance] - [Yesterday's balance]

 

 

speedramps_0-1662314283134.png

 

Greg_Deckler
Community Champion
Community Champion

@Anonymous So like this?

Measure =
  VAR __LastMonthDate = EOMONTH(TODAY(),-1)
  VAR __Last2MonthDate = EOMONTH(TODAY(),-2)
  VAR __LastMonth = MAXX(FILTER('Table',[Date]=__LastMonthDate),[Value])
  VAR __Last2Month = MAXX(FILTER('Table',[Date]=__Last2MonthDate),[Value])
RETURN
  __LastMonth - __Last2Month


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
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.

June 2025 community update carousel

Fabric Community Update - June 2025

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