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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. 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
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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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