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
Learner27
Helper III
Helper III

Assistance Needed: Complex Matrix Visual Requirements

Hello Community, I really need your help. and I'm requesting much-needed assistance from you.

My requirement is to use two Matrix visuals on a single tab. categories and their respective amounts. When I filter my slicers, if I select 2024 April, it should show me the values for April of this year and the prior year (2023) at the same time (Right). In the second visual, I need to display values from January to March, and in the total column, I need to show the year-to-date (YTD) average of those three months. Similarly, for May, if I select May 2024, the left-side visual should show values from January to April, with the YTD being the sum of the four months divided by four.

I have tried with different measures which doesn't give me proper out put I have Attached my sample Pbix file


DVT File.pbix


Thanks In advance


1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Learner27 ,

Unfortunately, I cannot open your sample Pbix file. I create a sample data to help you with your problem.
Sample data:

vyifanwmsft_0-1716448704967.png

1.Create a Date Table, and make a relationship between two tables. Put the DateTable into the Slicer.

vyifanwmsft_1-1716448809803.png

2.Add new measures.

In Matrix 1:

Current Year number =
CALCULATE (
    SUM ( 'Table'[number] ),
    FILTER (
        ALL ( 'Table'[Date] ),
        YEAR ( 'Table'[Date] ) = YEAR ( MAX ( 'Table'[Date] ) )
            && MONTH ( 'Table'[date] ) = MONTH ( MAX ( 'Table'[date] ) )
    )
)
Previous Year number =
CALCULATE (
    SUM ( 'Table'[number] ),
    FILTER (
        ALL ( 'Table'[Date] ),
        YEAR ( 'Table'[Date] )
            = YEAR ( MAX ( 'Table'[Date] ) ) - 1
            && MONTH ( 'Table'[date] ) = MONTH ( MAX ( 'Table'[date] ) )
    )
)

 

In Matrix 2:

YTD Average Amount =
VAR _endMonthDay =
    EOMONTH ( SELECTEDVALUE ( DateTable[Y&M] ), -1 )
VAR _monthCurrentSelectMonth =
    MONTH ( SELECTEDVALUE ( DateTable[Y&M] ) )
VAR _startMonthDay =
    EOMONTH ( SELECTEDVALUE ( DateTable[Y&M] ), -1 * _monthCurrentSelectMonth ) + 1
VAR _result =
    CALCULATE (
        SUM ( 'Table'[amount] ),
        'Table'[date] >= _startMonthDay
            && 'Table'[date] < _endMonthDay
    )
RETURN
    AVERAGEX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[date] >= _startMonthDay
                && 'Table'[date] < _endMonthDay
        ),
        CALCULATE ( SUM ( 'Table'[Amount] ) )
    )

 

Final output:

vyifanwmsft_2-1716449101553.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Learner27 ,

Unfortunately, I cannot open your sample Pbix file. I create a sample data to help you with your problem.
Sample data:

vyifanwmsft_0-1716448704967.png

1.Create a Date Table, and make a relationship between two tables. Put the DateTable into the Slicer.

vyifanwmsft_1-1716448809803.png

2.Add new measures.

In Matrix 1:

Current Year number =
CALCULATE (
    SUM ( 'Table'[number] ),
    FILTER (
        ALL ( 'Table'[Date] ),
        YEAR ( 'Table'[Date] ) = YEAR ( MAX ( 'Table'[Date] ) )
            && MONTH ( 'Table'[date] ) = MONTH ( MAX ( 'Table'[date] ) )
    )
)
Previous Year number =
CALCULATE (
    SUM ( 'Table'[number] ),
    FILTER (
        ALL ( 'Table'[Date] ),
        YEAR ( 'Table'[Date] )
            = YEAR ( MAX ( 'Table'[Date] ) ) - 1
            && MONTH ( 'Table'[date] ) = MONTH ( MAX ( 'Table'[date] ) )
    )
)

 

In Matrix 2:

YTD Average Amount =
VAR _endMonthDay =
    EOMONTH ( SELECTEDVALUE ( DateTable[Y&M] ), -1 )
VAR _monthCurrentSelectMonth =
    MONTH ( SELECTEDVALUE ( DateTable[Y&M] ) )
VAR _startMonthDay =
    EOMONTH ( SELECTEDVALUE ( DateTable[Y&M] ), -1 * _monthCurrentSelectMonth ) + 1
VAR _result =
    CALCULATE (
        SUM ( 'Table'[amount] ),
        'Table'[date] >= _startMonthDay
            && 'Table'[date] < _endMonthDay
    )
RETURN
    AVERAGEX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[date] >= _startMonthDay
                && 'Table'[date] < _endMonthDay
        ),
        CALCULATE ( SUM ( 'Table'[Amount] ) )
    )

 

Final output:

vyifanwmsft_2-1716449101553.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Anonymous 

It is wonderful that you have spent time on my query. It was really great, and thank you so much. I have created another post because this is not meeting my requirements.
However, I will use this one for my future needs. Please reply to my new post
and let me know if you can open my PBIX file. I have uploaded the latest PBIX file.

Once again, thank you so much!

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.