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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
medaxing
Frequent Visitor

DAX SSAS : Calculate days measure from another table

Hi Everyone,

I have few date fields in Dimension table, invoice date, due date and Paid date.

Based on the dates I need to calculate the Days Outstanding as a measure in the fact.

any help is really appreciated.

Thanks in advance.

 

invoice noinvoice datedue datePaiddateDays Outstanding 
2001-06-201901-07-201915-08-201945 paid date - due date
2201-07-201901-08-201901-10-201961 paid date - due date
2501-10-201903-10-2019 19today - due date
2802-10-201922-10-201915-10-2019-7 paid date - due date
2802-10-201903-11-2019  due date after today, then 0

 

Here is my dax, but it doesnt seem to work. 

 

SWITCH (
TRUE (),
ISBLANK('Sales Transaction Info'[Date of Paid]) &&
'Sales Transaction Info'[Due Date] < TODAY(), DATEDIFF ( 'Sales Transaction Info'[Due Date], TODAY(), DAY ),
DATEDIFF ( 'Sales Transaction Info'[Date of Paid], 'Sales Transaction Info'[Due Date], DAY ),
0
)

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi medaxing,

The sum of grand total =45 is automatical aggregation of Powerbi, it will refer to measure function(min) to use min value of each field to calculate. In addition, which part of result did you get 0, could you please inform me in details(by screenshots)?

By the way, you also could use calculated column to achieve this goal

Column = if(t2[due date]>TODAY() ,0 ,if(t2[Paiddate]=BLANK(), TODAY()-t2[due date],t2[Paiddate]-t2[due date]))

451.PNG

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
dax
Community Support
Community Support

Hi medaxing,

You could try below measure

Measure =
IF (
    MIN ( t2[due date] ) > TODAY (),
    0,
    IF (
        MIN ( t2[Paiddate] ) = BLANK (),
        TODAY () - MIN ( t2[due date] ),
        MIN ( t2[Paiddate] ) - MIN ( t2[due date] )
    )
)

443.PNG

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

medaxing
Frequent Visitor

Thanks for the quick response.

Somehow, I get zero as the result. also wondering how do get the sum as 45?

dax
Community Support
Community Support

Hi medaxing,

The sum of grand total =45 is automatical aggregation of Powerbi, it will refer to measure function(min) to use min value of each field to calculate. In addition, which part of result did you get 0, could you please inform me in details(by screenshots)?

By the way, you also could use calculated column to achieve this goal

Column = if(t2[due date]>TODAY() ,0 ,if(t2[Paiddate]=BLANK(), TODAY()-t2[due date],t2[Paiddate]-t2[due date]))

451.PNG

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.