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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. 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
Solution Specialist
Solution Specialist

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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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