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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. 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

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
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.

May 2025 Monthly Update

Fabric Community Update - May 2025

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