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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jlarques
Resolver I
Resolver I

Show rows only from this month

Dear community,

I have a table with sales data and I want to show it in a matrix the information of the current month, including days. For instance, now is July 2021 and I want to show a data matrix only with records of July 2021, not with all records since 1st January 2021. 

 

I was using this formula:

Sales by month=

CALCULATE(

    SUM(Sales[Total]);

    CALENDARIO[MONTH]=MONTH(TODAY()

)

but shows me all records since January 2021 with no data and I want only records from 1st July until today.

 

Any ideas to do that?

 

Thanks for all your support and help.

 

Kind regards,

 

 

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

@jlarques Hard to know for sure without sample data. Your formula seems overall to be correct although CALCULATE could be causing you some problems due to how it behaves. Are you missing a relationship between Sales and Calendario? Maybe:

Sales by month = 
  VAR __Table = FILTER('Sales',MONTH('Sales'[Date]) = MONTH(TODAY()))
RETURN
  SUMX(__Table,[Total])

 


@ 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

Hi @Greg_Deckler,

don't worry about that. 

 

I have modified other formulas to calculate last year and percentage following your formula and the calculations are correct.

 

Thanks again for your help, @Greg_Deckler

 

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@jlarques Hard to know for sure without sample data. Your formula seems overall to be correct although CALCULATE could be causing you some problems due to how it behaves. Are you missing a relationship between Sales and Calendario? Maybe:

Sales by month = 
  VAR __Table = FILTER('Sales',MONTH('Sales'[Date]) = MONTH(TODAY()))
RETURN
  SUMX(__Table,[Total])

 


@ 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 @Greg_Deckler,

thanks for your quick response.

 

The relationship between sales and the calendar is right and exists. 

 

The measure works. Thank you so much for your quick help!

 

I understand that I have to show the percentage between this month and the same month of last year, I'll have to calculate in the same way, to avoid that percentage can show me all records from January. Is this true?  

 

@jlarques Yes, it would be similar, logic for last year. I'm not sure I understand the last part about percentages and January.


@ 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 @Greg_Deckler,

don't worry about that. 

 

I have modified other formulas to calculate last year and percentage following your formula and the calculations are correct.

 

Thanks again for your help, @Greg_Deckler

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.