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
gonrodrigues
Helper III
Helper III

Custom Column Homologous Month

Hello,

 

To create colum Current Month I used this:

 

Table.AddColumn(MonthName, "CurrentMonth", each Date.IsInCurrentMonth( [Date] ))

and if I want to creat two more: "HomologousMonth" and "PreviousMonth"? I have this custom columns:

 

Data.jpg

 

I'm not familiar with DAX 😕

 

Thanks!

 

2 ACCEPTED SOLUTIONS

@gonrodrigues

 

They're DAX expressions, I was not using Power Query. Is Power Query necessary?

Capture.PNG

View solution in original post

@gonrodrigues

 

You can get the HomologousMonth with Date.IsInCurrentMonth as wellJust add one year to [Date] and predicate it with IsInCurrentMonth.

Table.AddColumn(PreviousMonth, "HomologousMonth", each Date.IsInCurrentMonth( Date.AddYears([Date],1) ))

Capture.PNG

If you have any question, feel free to let me know.

View solution in original post

9 REPLIES 9
Greg_Deckler
Super User
Super User

Can you explain what you want PreviousMonth to be? Do you want the actual previous month or do you want it to be a TRUE/FALSE value like CurrentMonth. And I have no idea what you are going for with HomologousMonth, is that the same as the current month in a different year? And is that also TRUE/FALSE or something else?


@ 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...

 

 Ok, there's a previous month Function and for homologous month? 

@gonrodrigues

Your requirement is not quite clear for me, please check if below DAX expressions work.

CurrentMonth = YEAR([date])=YEAR(TODAY()) && MONTH([date])=MONTH(TODAY())

previousMonth = YEAR([date])=YEAR(TODAY())&&MONTH([date])+1=MONTH(TODAY())

HomologousMonth = YEAR([date])+1=YEAR(TODAY())&&MONTH([date])=MONTH(TODAY())


Capture.PNG

 

If you have any question, feel free to let me know.

Yes, it works! But those 'New Columns' are not usable in Power Query? @Eric_Zhang

@gonrodrigues

 

They're DAX expressions, I was not using Power Query. Is Power Query necessary?

Capture.PNG

Is necessary to integrate with this expression:

 

Table.AddColumn(PreviousMonth, "MonthSlicer", each 
if [CurrentMonth] then "Current Month" 
else if [PreviousMonth] then "Previous Month" 
else [Month])

I already have current Month:

 

Table.AddColumn(MonthName, "CurrentMonth", each Date.IsInCurrentMonth( [Date] ))

and Previous Month:

 

Table.AddColumn(CurrentMonth, "PreviousMonth", each Date.IsInPreviousMonth( [Date] ))

 

I don't know if it was strictly necessary but i did it this way.

 

Thanks @Eric_Zhang

@gonrodrigues

 

You can get the HomologousMonth with Date.IsInCurrentMonth as wellJust add one year to [Date] and predicate it with IsInCurrentMonth.

Table.AddColumn(PreviousMonth, "HomologousMonth", each Date.IsInCurrentMonth( Date.AddYears([Date],1) ))

Capture.PNG

If you have any question, feel free to let me know.

Worked perfectly. Thanks a lot!

Hey @Greg_Deckler

 

I want both TRUE/FALSE. HomologousMonth would be the same month in previous year 🙂

 

Thanks

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.