Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Arif270182
Helper II
Helper II

formula for converting year & month from text to make comparison

Hi

 

I need support in converting my data which consist of months and year e.g. as below 

01 2017

02 2017

03 2017 

04 2017 & so far and so good & 

01 2018

02 2018

03 2018

04 2018 in same way 

the support what i need is to convert 2017 as Last year (LY) & 2018 as current year (CY) in order to compare month 1 CY vs LY.

 

Appreciate your feedback

 

regards 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

Not 100% on what you are going for here but perhaps this:

 

Column = IF(RIGHT([Column1],4)="2017","LY","CY")

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

v-yulgu-msft
Employee
Employee

Hi @Arif270182,

 

Please new measures:

CY = CALCULATE(SUM(table4[Sales]),FILTER(table4,table4[Year]=YEAR(TODAY())))

LY = CALCULATE(SUM(table4[Sales]),FILTER(table4,table4[Year]=YEAR(TODAY())-1))

Use a table visual to display data.

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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
v-yulgu-msft
Employee
Employee

Hi @Arif270182,

 

Please new measures:

CY = CALCULATE(SUM(table4[Sales]),FILTER(table4,table4[Year]=YEAR(TODAY())))

LY = CALCULATE(SUM(table4[Sales]),FILTER(table4,table4[Year]=YEAR(TODAY())-1))

Use a table visual to display data.

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

Not 100% on what you are going for here but perhaps this:

 

Column = IF(RIGHT([Column1],4)="2017","LY","CY")

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi 

 

thanks for below update it worked but now i have another challange  in arranging month from Jan to Dec, I have already arranged table month column  month sequence not arrangedmonth sequence not arranged

how can i fix this sequence 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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