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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.