cancel
Showing results for
Did you mean:
Frequent Visitor

## Compare current month vs previous month with available month column only

Hi,

help needed with DAX.

i have the fllowing table with product, month and result columns available. But i need to create trend and previous month result columns based on month and result columns using dax.

Please let me know how to do it.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator

## Re: Compare current month vs previous month with available month column only

@NPK,

https://1drv.ms/u/s!AhsotbnGu1NogywooC50WnB9h2pJ

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 REPLIES 3
Moderator

## Re: Compare current month vs previous month with available month column only

@NPK,

Create the following columns in your table.

```Index = COUNTROWS(FILTER(Table1,Table1[Product]=EARLIER(Table1[Product])&&Table1[Month]<=EARLIER(Table1[Month])))
```
```Previous month result = CALCULATE(FIRSTNONBLANK(Table1[Result],1),FILTER(Table1,Table1[Product]=EARLIER(Table1[Product]) && Table1[Index]=EARLIER(Table1[Index])-1))
```
```Trend = IF(ISBLANK(Table1[Previous month result]),BLANK(), SWITCH(
TRUE(),

(Table1[Result]-Table1[Previous month result]) <= 0, UNICHAR(128315),
(Table1[Result]-Table1[Previous month result]) >= .010,UNICHAR(9650),
BLANK()
))
```

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Frequent Visitor

## Re: Compare current month vs previous month with available month column only

Thanks v-yuezhe-msft for your quick response.

I exactly followed your steps, but i'm getting blank rows, am i missing something?

T

Thank you

Moderator

## Re: Compare current month vs previous month with available month column only

@NPK,

https://1drv.ms/u/s!AhsotbnGu1NogywooC50WnB9h2pJ

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Announcements

#### Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!