cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
NPK Frequent Visitor
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. 

Data.png

Please let me know how to do it.

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator v-yuezhe-msft
Moderator

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

@NPK,

Please review my PBIX file.

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.

View solution in original post

3 REPLIES 3
Moderator v-yuezhe-msft
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()
             ))

1.JPG
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.
NPK Frequent Visitor
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?

Product.PNGT

Thank you

Moderator v-yuezhe-msft
Moderator

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

@NPK,

Please review my PBIX file.

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.

View solution in original post

Helpful resources

Announcements
Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Users Online
Currently online: 72 members 1,090 guests
Please welcome our newest community members: