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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
bkbn
New Member

My matrix does not show the total per month and per year, how can I do?

Hello,

 
I think I have a problem with my matrix. Indeed, as you will see in the file "Matrix 1" in attachment, this one does not make sense since it is not classified in months and years. However, I did put the data in the right fields.
 
Matrix 1.JPG
 
I think that there is perhaps an error with my formula for the total sales. Here is my formula: "Total Sales = SUM(Sales[Revenue])" which you can also find in the attachment (Total Sales Formula).
 
Total sales formula.JPG
 
I tried to modify the formula by filtering it by month "Total Sales = CALCULATE(SUM(Sales[Revenue]), 'Date'[Month])". This way, a total sales is created for each month but it doesn't work. Indeed, I think the problem comes from the fact that it is a total over all the years and, therefore, the software is not able to display the total for each month and year.
 
Do you have any idea how I can solve this?
 
Thank you and have a nice day,
 
Sincerely,
4 REPLIES 4
mangaus1111
Solution Sage
Solution Sage

Try to use this calendar table.  For me it works good

 

Date =
VAR MinYear = YEAR ( MIN ( 'Sales'[Date] ) )
VAR MaxYear = YEAR ( MAX ( 'Sales'[Date] ) )
RETURN
ADDCOLUMNS (
    FILTER (
        CALENDARAUTO( ),
        AND ( YEAR ( [Date] ) >= MinYear, YEAR ( [Date] ) <= MaxYear )
    ),
    "Year", YEAR ( [Date] ),
    "Month Name", FORMAT ( [Date], "mmmm" ),
    "Month Name Short", FORMAT ( [Date], "mmm" ),
    "Month-Year", FORMAT ( [Date], "mmm" )&"-"& RIGHT([Date],2),
    "Quarter Number", QUARTER ([Date]),  
    "Quarter", "Q" & TRUNC ( ( MONTH ( [Date] ) - 1 ) / 3 ) + 1,                                
    "Month Number", MONTH ( [Date] ),
    "Weekday", FORMAT ( [Date], "dddd" ),
    "Weekday number", WEEKDAY( [Date] ),
    "Year*Month",YEAR ( [Date] )*100 + MONTH ( [Date] )
)
 
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
mangaus1111
Solution Sage
Solution Sage

Hi @bkbn ,

 

did you create a relationship between your calendar table and fact table?

Hello, thank you for your help. Yes I have a relationship : 

Relation.JPG

@bkbn , The measure does not seem right to me. If you have date, with help from the date joined with the date table you can have measure like

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))

 

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.