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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculation Of Due in Next 30 days

I am trying to calculate list of documents which are Due in Next 30 days (Including Today).

Tried multiple ways however not getting the correct numbers. Can you please correct me ?

The condition is either [Due In Date] OR [Forecast Submission Date] should be in next 30 days and I am trying the below DAX.

Documents due in next 30 days =
CALCULATE (
    [Total Documents],
    FILTER ( 'Merged Table', 'Merged Table'[Actual In] = BLANK () ),
    OR (
        DATESBETWEEN ('Merged Table'[Due In Date], TODAY (), TODAY () + 30 ),
        DATESBETWEEN ('Merged Table'[Forecast Submission Date], TODAY (), TODAY () + 30 )
    )

 

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

pls try this

 

Documents due in next 30 days =
VAR _toDay = TODAY ()
VAR _End = _toDay+30
RETURN
CALCULATE (
    [Total Documents],
    ALL('Merged Table'),
     'Merged Table'[Actual In] = BLANK () ,
      OR (
        'Merged Table'[Due In Date]>=,_toDay&& () 'Merged Table'[Due In Date]<=_End,
        'Merged Table'[Forecast Submission Date]>=,_toDay&& () 'Merged Table'[Forecast Submission Date]<=_End
    )
-------OR-----
Documents due in next 30 days =
VAR _toDay = TODAY ()
VAR _End = _toDay+30
RETURN
CALCULATE (
    [Total Documents],
     'Merged Table'[Actual In] = BLANK () ,
      OR (
        'Merged Table'[Due In Date]>=,_toDay&& () 'Merged Table'[Due In Date]<=_End,
        'Merged Table'[Forecast Submission Date]>=,_toDay&& () 'Merged Table'[Forecast Submission Date]<=_End
    )

 

View solution in original post

7 REPLIES 7
Ahmedx
Super User
Super User

pls try this

 

Documents due in next 30 days =
VAR _toDay = TODAY ()
VAR _End = _toDay+30
RETURN
CALCULATE (
    [Total Documents],
    ALL('Merged Table'),
     'Merged Table'[Actual In] = BLANK () ,
      OR (
        'Merged Table'[Due In Date]>=,_toDay&& () 'Merged Table'[Due In Date]<=_End,
        'Merged Table'[Forecast Submission Date]>=,_toDay&& () 'Merged Table'[Forecast Submission Date]<=_End
    )
-------OR-----
Documents due in next 30 days =
VAR _toDay = TODAY ()
VAR _End = _toDay+30
RETURN
CALCULATE (
    [Total Documents],
     'Merged Table'[Actual In] = BLANK () ,
      OR (
        'Merged Table'[Due In Date]>=,_toDay&& () 'Merged Table'[Due In Date]<=_End,
        'Merged Table'[Forecast Submission Date]>=,_toDay&& () 'Merged Table'[Forecast Submission Date]<=_End
    )

 

Anonymous
Not applicable

Hi @Ahmedx ,

Your second solution is right and is working well.

However, there is another requirement now in the same DAX is below-

Latest of (Forecast Date > today +30 and Forecast date <= today+30) and (Due in Date > today+30 and Due in date <= today+30)

We need to consider the Latest of either Forecast Date OR DueIn Date.

I don’t understand, but this is a new question, create a new topic and explain in detail what you need and expect the result

you mean that today it will be + 30
this

Screenshot_1.png

philouduv
Resolver III
Resolver III

Could you shre the data model so we can adapt the formula, because it works on my fake table ?
If you want to Count you could use this : 

due 30 = CALCULATE(COUNTROWS(Table911),FILTER(Table911,
DATEDIFF(TODAY() ,Table911[due date].[Date],DAY) <= 30 || DATEDIFF(TODAY() ,Table911[forecast date].[Date],DAY) <= 30))
philouduv
Resolver III
Resolver III

Hello @Anonymous ,
I tried to create a calculated column in a table and putted Yes if need to be process and No if not, then you can filter it on visual 
Formula:

due 30 = IF(DATEDIFF(TODAY() ,Table911[due date].[Date],DAY) <= 30 || DATEDIFF(TODAY() ,Table911[forecast date].[Date],DAY) <= 30, "Yes", "No")

NB: the formula  will also consider past date, if you want to avoid that, filter on date >= from Today


Best regards
Anonymous
Not applicable

Appreciate your effort however, this doesn't work.

Need to show how many are due in next 30 days i.e. Count Of Documents

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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