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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
gauthamboppana
Solution Specialist
Solution Specialist

Display products with sales in the latest month in a matrix showing rolling 6-month sales

Hi all,

I have a Matrix Visual showing rolling 6 months sales by Product.  The one requirement is to hide the products that do not have any sales in the latest period. For exmaple, in the below screenshot I have selected Dec 2024. There are no sales for Product E. So product E should not be displayed in the Matrix.

Can any one help? 

I have attached the sample PBIX file.
Linkt-To-Downlaod-Sample-PBIX-File 

gauthamboppana_0-1726478797788.png


This is my DAX formula for calculating the last 6 months sales.

SalesLast6Months =
VAR MaxVisibleDate = MAX('DateTable'[Date])
VAR MinVisibleDate = EDATE(MaxVisibleDate, -5)  -- 6 months
RETURN
CALCULATE(
    SUM(Sales[SalesAmount]),
    FILTER(
        ALL('DateTable'),
        'DateTable'[Date] <= MaxVisibleDate &&
        'DateTable'[Date] >= MinVisibleDate
    )
)


Thank you




1 REPLY 1
Selva-Salimi
Super User
Super User

Hi @gauthamboppana 

 you can update your measure as follows:

 

SalesLast6Months =
VAR MaxVisibleDate = MAX('DateTable'[Date])
VAR MinVisibleDate = EDATE(MaxVisibleDate, -5)  -- 6 months
VAR Last_Products = Summarize(filter(sales , sales[date] = maxVisibleDate) , [Products])
RETURN
CALCULATE(
    SUM(Sales[SalesAmount]),
    FILTER(
        ALL('DateTable'),
        'DateTable'[Date] <= MaxVisibleDate &&
        'DateTable'[Date] >= MinVisibleDate
    ) , 
     Filter (Sales , Sales [Product] in Last_products )
)

 

 

If this post helps, then I would appreciate a thumbs up  and mark it as the solution to help the other members find it more quickly. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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