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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
sanjaymithran
Helper I
Helper I

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 I
Helper I

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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