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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

DIFFERENCE BETWEEN MULTIPLE DATES

Hi

I have a table with different sales dates X product , i want to put them on a visualisation matrice to have the difference between each sales date filtered by product name as showed below

 

I'm looking for a dax formula to calculate ''DIFFERENCE''

 

FILTER : Cars

SELL DATEDIFFERENCE
13/01/2023 
14/01/2023                  1
18/01/2023                  4
26/01/2023                  8
04/02/2023                  9
07/02/2023                  3
                 …

 

FILTER : Trucks

SELL DATEDIFFERENCE
14/01/2023 
18/01/2023                  4
19/01/2023                  1
21/01/2023                  2
04/02/2023                14
07/02/2023                  3
                 …
3 REPLIES 3
grazitti_sapna
Super User
Super User

Hey, you can try using

DIFFERENCE =

VAR CurrentProduct = SELECTEDVALUE('Product'[Product Name])

VAR CurrentDate = SELECTEDVALUE('Sales'[Sell Date])

RETURN

CALCULATE(

MIN('Sales'[Sell Date]) - CurrentDate,

FILTER(

ALL('Sales'),

'Sales'[Product Name] = CurrentProduct &&

'Sales'[Sell Date] < CurrentDate

)

)

Thank you. Hope this will help

Anonymous
Not applicable

Hi Thanks but this is giving me a date as result and not a number

Hey,
You can try using
DIFFERENCE =
VAR CurrentProduct = SELECTEDVALUE('Product'[Product Name])
VAR CurrentDate = SELECTEDVALUE('Sales'[Sell Date])
RETURN
DATEDIFF(
    MINX(
        FILTER(
            'Sales',
            'Sales'[Product Name] = CurrentProduct &&
            'Sales'[Sell Date] < CurrentDate
        ),
        'Sales'[Sell Date]
    ),
    CurrentDate,
    DAY
)
Thnak you
Hope this will help. 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.