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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
sanjaymithran
Helper II
Helper II

Show YTD Months in Column (Matrix) based selected Month in Slicer

Hi ,

I need to create Matrix visual like below based on Month-Year slicer selection need to display YTD

Ex:1 Slicer  selection is Feb-24 then show as below

sanjaymithran_0-1719242133867.png

Ex:2 Slicer selection is  Dec-23 then Jan-23 to Dec-23 to show in column

 

I have tried some logic its working in table but not in Matrix

 

Thanks,

Sanjay

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @sanjaymithran ,

Please create another 2 new measures as below and replace the original measure [Sales] and [Profit] on the matrix:

New_Sales = SUMX(VALUES('Table'[Date]),[Sales])
New_Profit = SUMX(VALUES('Table'[Date]),[Profit])

vyiruanmsft_0-1719365806788.png

Best Regards

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @sanjaymithran,

You can follow the steps below to get it:

1. Create a separate date dimension table(DO NOT create any relationship with your fact table)

vyiruanmsft_0-1719280852283.png

2. Create a measure as below to get YTD

YTD =
VAR _yearmonth =
    SELECTEDVALUE ( 'Date'[YearMonth] )
VAR _year =
    VALUE ( RIGHT ( _yearmonth, 4 ) )
VAR _month =
    SWITCH (
        LEFT ( _yearmonth, 3 ),
        "Jan", 1,
        "Feb", 2,
        "Mar", 3,
        "Apr", 4,
        "May", 5,
        "Jun", 6,
        "Jul", 7,
        "Aug", 8,
        "Sep", 9,
        "Oct", 10,
        "Nov", 11,
        "Dec", 12
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            'Table',
            YEAR ( 'Table'[Date] ) = _year
                && MONTH ( 'Table'[Date] ) <= _month
        )
    )

vyiruanmsft_1-1719280913654.png

Best Regards

Hi Yirvuan,

Thanks for your suggesstion, But Sales and Profit is separate measure (Calculated field)

Sales=Price*qty and Profit=selling price- cost price

 

Thanks,

Sanjay.

PREVIEW
 
 
 
Anonymous
Not applicable

Hi @sanjaymithran ,

I updated my sample pbix file(see the attachment), please check if that is what you want. You can toggle on the option "Switch values to rows".

vyiruanmsft_0-1719295847538.png

Toggle on "Switch values to rows"Toggle on "Switch values to rows"

Best Regards

Hi Yiruvan,

This is working fine but column sub total is not displaying,

is there any way apply filter date column only because have 8 measures and each measure has already 100 lines

Thanks,

Sanjay

Anonymous
Not applicable

Hi @sanjaymithran ,

Please create another 2 new measures as below and replace the original measure [Sales] and [Profit] on the matrix:

New_Sales = SUMX(VALUES('Table'[Date]),[Sales])
New_Profit = SUMX(VALUES('Table'[Date]),[Profit])

vyiruanmsft_0-1719365806788.png

Best Regards

Hi yiruan,

when we used percentage field  in sub total just shows sum of percentage,its not show correctly

Show YTD Months in Column (Matrix) based selected Month in Slicer(Updated2) you shared this file example here created margin %=sales/profit as you mentioned formula individually coming correctly but total is wrong because final formula used sumx tried with averagex but not getting correct result

sanjaymithran_0-1720186750225.png

 

Thanks,

Sanjay

sanjaymithran
Helper II
Helper II

Hi ,

I need to create Matrix visual like below based on Month-Year slicer selection need to display YTD

Ex:1 Slicer  selection is Feb-24 then show as below

sanjaymithran_0-1719242133867.png

Ex:2 Slicer selection is  Dec-23 then Jan-23 to Dec-23 to show in column

 

I have tried some logic its working in table but not in Matrix

 

Thanks,

Sanjay

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.