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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
raymondvis
Frequent Visitor

Month filter

Hello,

 

I can't figure out how to arrange a filter that filters a table based on the current month. For the example table below I would like to use the following DAX measure:

Filter = From monthnr <= Month(Today () ) AND Until monthnr >= Month(Today () )

 

But this will not work for article C. If the current monthnr is 1, 2 or 3, article C should be returned but it will not because the 'From monthnr' argument is not valid. How can I solve this?

 

ArticleFrom monthFrom monthnrUntil monthUntil monthnr
AJanuary1April4
BJuly7August8
CNovember11March3

 

Hopefully you have an idea. Thank you in advance!

Raymond

1 ACCEPTED SOLUTION

Thanks for the assist, but this still leaves the problem with article C for months 11 and 12 as they will result in "No" due to the last argument for MONTH (TODAY () ) <= [Until Month].

I think I have found a solution by using the month numbers to create a date with new columns:


From period =
IF(
[From month] > [Until month]
&& [From month] > MONTH( TODAY() ),
DATE(
YEAR( TODAY() ) -1,
[From month],
1
),
DATE(
YEAR( TODAY() ),
[From month],
1
)
)


Until period =
VAR MonthNr = [Until month]
VAR Year =
IF(
[From month] > [Until month]
&& [From month] <= MONTH( TODAY() ),
YEAR( TODAY() ) +1,
YEAR( TODAY() )
)
VAR DayNr =
CALCULATE(
MAX( DateTable[Day of month] ),
DateTable[Month Number] = MonthNr,
DateTable[Year] = Year
)

RETURN
IF(
[From month] > [Until month]
&& [From month] <= MONTH( TODAY() ),
DATE(
YEAR( TODAY() ) +1,
[Until month],
DayNr
),
DATE(
YEAR( TODAY() ),
[Until month],
DayNr
)
)

View solution in original post

5 REPLIES 5
Syndicate_Admin
Administrator
Administrator

@raymondvis

You can only add another condition in case the larger month is large than the month so far.

Column - IF([From month]>[Until month] & & MONTH (TODAY())<-[Until the month],"Yes",
IF(MONTH(TODAY())>-[From month] & & MONTH (TODAY())<-[Until month],"Yes", "No"))
V-pazhen-msft_0-1619576346121.png

Paul Zheng _ Community Support Team
If this post helps, please accept it as the solution to help other members find it faster.

Thanks for the assist, but this still leaves the problem with article C for months 11 and 12 as they will result in "No" due to the last argument for MONTH (TODAY () ) <= [Until Month].

I think I have found a solution by using the month numbers to create a date with new columns:


From period =
IF(
[From month] > [Until month]
&& [From month] > MONTH( TODAY() ),
DATE(
YEAR( TODAY() ) -1,
[From month],
1
),
DATE(
YEAR( TODAY() ),
[From month],
1
)
)


Until period =
VAR MonthNr = [Until month]
VAR Year =
IF(
[From month] > [Until month]
&& [From month] <= MONTH( TODAY() ),
YEAR( TODAY() ) +1,
YEAR( TODAY() )
)
VAR DayNr =
CALCULATE(
MAX( DateTable[Day of month] ),
DateTable[Month Number] = MonthNr,
DateTable[Year] = Year
)

RETURN
IF(
[From month] > [Until month]
&& [From month] <= MONTH( TODAY() ),
DATE(
YEAR( TODAY() ) +1,
[Until month],
DayNr
),
DATE(
YEAR( TODAY() ),
[Until month],
DayNr
)
)

Anonymous
Not applicable

@raymondvis 

You can just add another condition in case the from month is large than the until month.

 

Column = IF([From month]>[Until month] && MONTH(TODAY())<=[Until month],"Yes",
IF(MONTH(TODAY())>=[From month] && MONTH(TODAY())<=[Until month],"Yes", "No"))
V-pazhen-msft_0-1619576346121.png

 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@raymondvis ,The information you have provided is not making the problem clear to me. Can you please explain with an example.
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Appreciate your Kudos.

 

See if time intelligence can help

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Wel basically the table remains the same, only the month names are not included. The articles are to be ordered within a certain period which is indicated in month numbers. But these periods are not year based, they are month based. Therefore I cannot use a date like November 2020 until May 2021, but only November until May. 

 

Below you find the sample table once again. 

The column ( I only added this column as an example):

Current month = MONTH( TODAY() ) 

 

The column: Is it in period =
VAR CurrentMonth = MONTH( TODAY() )

RETURN
IF(
Blad2[From month] <= CurrentMonth
&& Blad2[Until month] >= CurrentMonth,
"Yes",
"No"
)

 

ArticleFrom monthUntil monthIs it in periodCurrent month
A14Yes4
B78No4
C115No4
D15Yes4
D1112No4


Article C should be included as a Yes, because month 4 is in between the period month 11 to month 5. It is not an option to include the data like Article D, because then I would be adding 2 lines instead of 1.

 

Any thoughts on how to fix this?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors