Camilla
Camilla

Reputation: 43

How to calculate sum of amount for current month including the amount of previous months in Power Bi?

I would like to create DAX expression. This is the condition and I have my month and year table in separate column.

If we choose Month as a March then it should show the sum of amount of Jan, Feb and as well as March. Similarly, If we choose Month as Dec then it should have the sum from Jan to Dec.

How can we write DAX expression for this condition in Power Bi?

Upvotes: 0

Views: 5092

Answers (1)

mkRabbani
mkRabbani

Reputation: 16908

You probably need a measure as below. You need to have a separate Date/Calendar table for that which is connected to your Data table using Date column.

total_amount_ytd = 
CALCULATE(
    SUM(your_table_name[your_amount_column_name]),
    DATESYTD(your_date_table_name[your_date_column_name])
)

With this above Measure, if you add Year/Month in a table with the new Measure, you will find the value per year will increase from January to December for a single year and starts re calculating from January again in the next year.

Upvotes: 0

Related Questions