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

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

Reply
Shadaiv
Helper II
Helper II

How to get the maximum date from two dates of same month

Hi Experts,

Need your help here.

I am using a line graph, where in X axis i am using Dates and Y axis - Paid Amount.

Each month, the payment is made twice which is fortnighly. So in the line graph i want to show only the maximun date from the given month when the payment was made. How should i create a flag or column which will show only the maximum date from given dates of same month as shown below (Expected)

Current

Shadaiv_0-1632900353342.png

 

Expected

Shadaiv_1-1632900445181.png

Thanks

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Shadaiv Well, one way would be to create a Complex Selector: The Complex Selector - Microsoft Power BI Community In your case maybe:

Selector Measure = 
  VAR __CurrentDate = MAX('Table'[Date])
  VAR __Year = YEAR(__CurrentDate)
  VAR __Month = MONTH(__CurrentDate)
  VAR __Table = FILTER(ALLSELECTED('Table'), [Date] < __CurrentDate && YEAR([Date])=__Year && MONTH([Date])=__Month)
RETURN
  IF(ISBLANK(__Table),1,0)

You could also do this in a colum like:

Selector Measure = 
  VAR __CurrentDate = 'Table'[Date]
  VAR __Year = YEAR(__CurrentDate)
  VAR __Month = MONTH(__CurrentDate)
  VAR __Table = FILTER('Table', [Date] < __CurrentDate && YEAR([Date])=__Year && MONTH([Date])=__Month)
RETURN
  IF(ISBLANK(__Table),1,0)


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

@Shadaiv Well, one way would be to create a Complex Selector: The Complex Selector - Microsoft Power BI Community In your case maybe:

Selector Measure = 
  VAR __CurrentDate = MAX('Table'[Date])
  VAR __Year = YEAR(__CurrentDate)
  VAR __Month = MONTH(__CurrentDate)
  VAR __Table = FILTER(ALLSELECTED('Table'), [Date] < __CurrentDate && YEAR([Date])=__Year && MONTH([Date])=__Month)
RETURN
  IF(ISBLANK(__Table),1,0)

You could also do this in a colum like:

Selector Measure = 
  VAR __CurrentDate = 'Table'[Date]
  VAR __Year = YEAR(__CurrentDate)
  VAR __Month = MONTH(__CurrentDate)
  VAR __Table = FILTER('Table', [Date] < __CurrentDate && YEAR([Date])=__Year && MONTH([Date])=__Month)
RETURN
  IF(ISBLANK(__Table),1,0)


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler 

 

Thank you so much for your reply.

I tried both DAX column and Measure but getting below error :
"The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."
Measure

Shadaiv_0-1632993082362.png

 

Column

Shadaiv_1-1632993206620.png

Please let me know if i am missing something.

Thanks

@Shadaiv Sorry, use ISBLANK(COUNTROWS(__Table)) in the IF condition.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank you so much @Greg_Deckler . It worked 🙂

 

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.