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

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

Reply
Anonymous
Not applicable

How to dynamically populate a column based on the slicer selection?

Hi Everyone,

 

My requirement is to dynamically show a column based on the slicer selection. For Example, Let us consider this to be the Sample data. We need to show the Last 3 Years Average Values as an individual column in a Matrix visual. 

YearAreaScore
2019A15
2019A22
2020A13
2020A24
2020A32
2020A45
2020A53
2021A12
2021A23
2021A31

 

We have Year, Area and Scores assigned for each Area (Out of 5). We need to Calculate the Average Score Values for each Year and that should shown as an individual column. My Output should look like the below in the Matrix Visual. Each Year Name should be created as a new column and corresponding average value should be shown.

REQUIRED OUTPUT TABLE:

Area201920202021
A13.532
A2032
A3040

 

In the Year Slicer, If I select "2021", it should correspondingly display the output as shown above. If we cant able to show the Last Year's data, then we need to show that corresponding slicer selection data. (Say), If I select 2019 in Year slicer, it should display the output as below.

Area2019
A13.5
A20
A30

 

Help me in creating the dynamic Columns as 2019, 2020, 2021(shown in the required Output Table) etc for each Year's Average value and filter it based on the slicer selection. And Is it possible to show the Last 3 Year's data in Matrix Visual?

 

This is an urgent requirement. Please help me with your solution in PBIX file or DAX query, that would be helpful.

Thankyou in advance !!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

First, please create a year dimension table(don't create any relationship with your fact table).

Years = VALUES('Table'[Year])

Then create a measure as below to get the average of score. You can find all details in the attachment.

Average of score = 
CALCULATE (
    AVERAGE ( 'Table'[Score] ),
    FILTER ( 'Table', 'Table'[Year] <= SELECTEDVALUE ( 'Years'[Year] ) )
)

yingyinr_0-1625644420825.png

Best Regards

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi Everyone,

 

Please do post your solutions over here, so that I can able to sort out this issue asap.

Thanks!!

Anonymous
Not applicable

Hi @Anonymous ,

First, please create a year dimension table(don't create any relationship with your fact table).

Years = VALUES('Table'[Year])

Then create a measure as below to get the average of score. You can find all details in the attachment.

Average of score = 
CALCULATE (
    AVERAGE ( 'Table'[Score] ),
    FILTER ( 'Table', 'Table'[Year] <= SELECTEDVALUE ( 'Years'[Year] ) )
)

yingyinr_0-1625644420825.png

Best Regards

Anonymous
Not applicable

Hi @Anonymous

 

Thankyou very much for a quick solution on this issue. But to add on to that, what if we have more than 1 measure to display in that same matrix chart?

In that case, the column values of the year are not dynamically populating as last 3 years based on slicer selection. I need the same exact solution you have provided (i.e) The column name should be 2021, 2020 & 2019 , if we select 2021 in the Year selection, along with some other measures too. I have added a measure called "Global Avg", if we add that measure, then Year name changing as a column header. That should not happen as per the requirement.

 

Global Avg is calculated as follows,

Global Avg = CALCULATE(AVERAGE('Table'[Score]),ALLEXCEPT('Table','Table'[Area],'Table'[Year]))

 

The expected output is,

 

Area201920202021Global Avg
A13.5323
A20322.5
A30404

 

 

Can you please help me in achieving this asap? This needs to be fixed in a short notice. Your guidance will be really helpful. 

Thanks !!

amitchandak
Super User
Super User

@Anonymous , is this not a matrix display with year on slicer and year on matrix column?

 

https://docs.microsoft.com/en-us/power-bi/visuals/desktop-matrix-visual

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak , Year is a slicer and we need the Output as Average values for each Year with its corresponding Areas. Can we able to achieve the required logic which I mentioned in the above problem statement?

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.