Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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:
I'm not familiar with DAX 😕
Thanks!
Solved! Go to Solution.
They're DAX expressions, I was not using Power Query. Is Power Query necessary?
You can get the HomologousMonth with Date.IsInCurrentMonth as well. Just add one year to [Date] and predicate it with IsInCurrentMonth.
Table.AddColumn(PreviousMonth, "HomologousMonth", each Date.IsInCurrentMonth( Date.AddYears([Date],1) ))
If you have any question, feel free to let me know.
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?
Ok, there's a previous month Function and for homologous month?
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())
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
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
You can get the HomologousMonth with Date.IsInCurrentMonth as well. Just add one year to [Date] and predicate it with IsInCurrentMonth.
Table.AddColumn(PreviousMonth, "HomologousMonth", each Date.IsInCurrentMonth( Date.AddYears([Date],1) ))
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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 47 | |
| 44 | |
| 40 | |
| 18 | |
| 18 |
| User | Count |
|---|---|
| 70 | |
| 68 | |
| 33 | |
| 32 | |
| 32 |