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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Responsive Resident
Responsive Resident

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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