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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
razieh1990
Helper I
Helper I

fitler data

Hello 

I appreciate it if you help me.

I have a dataset including all the sales from 2018. 

I want to create a matrix in Power BI similar to the below layout. 

On the page there is a year selection, each year I choose in the slicer, the data for that year should be displayed by month, and also the target should display the target of the selected year and for the rest of the years, the data should be aggregated and displayed yearly.

and the columns should be sorted ascending. for example, if I choose 2022: the layout should be like the matrix below.

for 2024:

image.jpeg

for 2022:

 

 

photo_2024-03-08 14.39.51.jpeg

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @razieh1990 ,

I updated your sample pbix file(see the attachment), please check if that is what you want.

 

MSales = 
VAR _years =
    ALLSELECTED ( 'Years'[Year] )
VAR _year =
    SELECTEDVALUE ( 'Data'[Year] )
VAR _month =
    SELECTEDVALUE ( 'Months'[Month] )
RETURN
    IF (
        _year
            IN _years && ISINSCOPE ( 'Months'[Month] ),
        SUM ( Data[Sale] ),
        IF (
            NOT ( _year IN _years )
                && ISINSCOPE ( 'Data'[Year] )
                && NOT ( ISINSCOPE ( 'Months'[Month] ) ),
            SUM ( 'Data'[Sale] ),
            BLANK ()
        )
    )
MTarget = 
VAR _years =
    ALLSELECTED ( 'Years'[Year] )
RETURN
    IF (
        SELECTEDVALUE ( 'Data'[Year] )
            IN _years && ISINSCOPE ( 'Data'[Year] )
                && NOT ( ISINSCOPE ( 'Months'[Month] ) ),
        SUM ( 'Data'[Target] )
    )

 

vyiruanmsft_0-1710489669024.png

Best Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @razieh1990 ,

Base on your description, it seems that you want to create a matrix visual. And when you select the year 2020, it will display the target values for the selected year(s) with the months. For the left years, it will display the sales with the left years. Could you please provide some raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Hello , 

here is the power bi file I tried to explain my logic and what I want in this power bi file . I appreciate your time https://we.tl/t-0e0eRtGnjY 

Anonymous
Not applicable

Hi @razieh1990 ,

I updated your sample pbix file(see the attachment), please check if that is what you want.

 

MSales = 
VAR _years =
    ALLSELECTED ( 'Years'[Year] )
VAR _year =
    SELECTEDVALUE ( 'Data'[Year] )
VAR _month =
    SELECTEDVALUE ( 'Months'[Month] )
RETURN
    IF (
        _year
            IN _years && ISINSCOPE ( 'Months'[Month] ),
        SUM ( Data[Sale] ),
        IF (
            NOT ( _year IN _years )
                && ISINSCOPE ( 'Data'[Year] )
                && NOT ( ISINSCOPE ( 'Months'[Month] ) ),
            SUM ( 'Data'[Sale] ),
            BLANK ()
        )
    )
MTarget = 
VAR _years =
    ALLSELECTED ( 'Years'[Year] )
RETURN
    IF (
        SELECTEDVALUE ( 'Data'[Year] )
            IN _years && ISINSCOPE ( 'Data'[Year] )
                && NOT ( ISINSCOPE ( 'Months'[Month] ) ),
        SUM ( 'Data'[Target] )
    )

 

vyiruanmsft_0-1710489669024.png

Best Regards

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors