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
Ponn1510
New Member

Show rows of a matrix based on a condition

Hi Experts,

 

I am trying to create a matrix visual that takes two hierarchy levels - Category1 and Category2 as rows.
Weeknum as columns. Value column is to be shown as value.
I am using a range slicer that limits the columns shown in matrix. Data is something like this

Category1Category2WeekNumValue
FruitsABC202401155
 DEF202404209
 ABC202352567
VeggiesDEF202401264
 GHL202353449
 GHL202401699


I am trying to show only rows that have value for selected top range weeknum and show values for previous weeks(columns) only for those rows.

For Example, If Weeknum slicer is selected as 202301 to 202401, Then
selected top range weeknum - 202401
Rows that have data in 202401:

FruitsABC202401155
VeggiesDEF202401264
VeggiesGHL202401699


So final expected Matrix should look like

Category1Category2202401202353202352...202301
FruitsABC1550567 0
VeggiesDEF26400 0
VeggiesGHL6994490 0


Kindly help me with ways of achieving this.

I tried different approaches like dax measure for value to be shown, also tried table functions with different filters but unable to show the dax table in matrix.

Help is much appreciated, TIA.

1 ACCEPTED SOLUTION
Sahir_Maharaj
Super User
Super User

Hello @Ponn1510,

 

Can you please try this approach:

 

1. Identify Top Range WeekNum

TopRangeWeekNum = 
MAXX(
    FILTER(
        ALLSELECTED('YourDataTable'),
        'YourDataTable'[WeekNum] <= MAX('YourDataTable'[WeekNum])
    ),
    'YourDataTable'[WeekNum]
)

2. Filter Values

FilteredValue = 
VAR TopWeekNum = [TopRangeWeekNum]
RETURN
IF (
    CALCULATE(
        COUNTROWS('YourDataTable'),
        FILTER(
            'YourDataTable',
            'YourDataTable'[WeekNum] = TopWeekNum
        )
    ) > 0,
    SUM('YourDataTable'[Value]),
    BLANK()
)

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

View solution in original post

1 REPLY 1
Sahir_Maharaj
Super User
Super User

Hello @Ponn1510,

 

Can you please try this approach:

 

1. Identify Top Range WeekNum

TopRangeWeekNum = 
MAXX(
    FILTER(
        ALLSELECTED('YourDataTable'),
        'YourDataTable'[WeekNum] <= MAX('YourDataTable'[WeekNum])
    ),
    'YourDataTable'[WeekNum]
)

2. Filter Values

FilteredValue = 
VAR TopWeekNum = [TopRangeWeekNum]
RETURN
IF (
    CALCULATE(
        COUNTROWS('YourDataTable'),
        FILTER(
            'YourDataTable',
            'YourDataTable'[WeekNum] = TopWeekNum
        )
    ) > 0,
    SUM('YourDataTable'[Value]),
    BLANK()
)

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

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.

Top Solution Authors