Get previous month value Power BI DAX

49 views Asked by At

I have a table with the following measures and columns

enter image description here

the "net month" and "beginning balance" columns are measures, I want to get the "balance" column which is calculated as follows

  • for the month of January balance= beginning balance + net month
  • for the month of February balance = balance (January) + net month (February)
  • for the month of March balance = balance (February) + net month (March)
  • for the month of April balance = balance (March) + net month (April)

and so on. Any ideas for a measure or function I can use?

Thank you very much in advance

1

There are 1 answers

0
Sam Nseir On

You will need a proper Date column, it can be set for the 1st day of the month.

Then your measure could look like this:

Balance = 
  var mnths =
    SUMMARIZE(
      FILTER('YourTable', [Date] <= MIN('YourTable'[Date])),
      "netM", [net month]
    )
  return [beginning balance] + SUMX(mnths, [netM])