Forum Discussion

CracktheCode85's avatar
2 years ago

DAX Date Filters based on two date columns

Hi Brilliant folks! 

 

I'm having trouble determining a correct conditional filter for two date filters for an Outstanding Balance: 

The two Date columns are:

1.) Month End Dates (April 30, May 31 etc...)

2.) Due Dates ; Ranges from 2020 to December 2024. 

 

Im working on a formula that calculates the Previous Months Outstanding Balance based on the following criteria:

The Due Date is less than or equal to the Current Month. 

 

My question is how do I accurately capture this criteria with two date fields? 

 

VAR current_month = [Current Month]
RETURN
CALCULATE([Prior_Outstanding], 'Table'[Month & Year (Due_Date)] <= current_month)

2 Replies

  • CracktheCode85 ,

    Prefer a date table, assuming current month coming from selection of today

     

    Current Month = if(isfiltered('Date'), Max('Date'[Date]), today())

     

     

    Last month end date =

    VAR current_month = eomonth([Current Month],-1)
    RETURN
    CALCULATE([Prior_Outstanding], filter( all ('Date'), Date'[Date] = current_month)
     
    In case date and the table is not joined you can tables columns.
     
    You can also use closingbalancemonth
     
    Power BI closingbalancemonth closingbalancequarter closingbalanceyear, lastnonblankvalue- Closing Balance, Distibutre Target: https://youtu.be/yPQ9UV37LOU
     
    Why previousmonth does not give result when datesmtd is giving it: https://youtu.be/1KkoJehRVeg
     
    Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
    https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5bd4
    To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

    • CracktheCode85's avatar
      CracktheCode85
      Icon for Helper II rankHelper II

      Is it sandard practice to create a custom calendar for each dashboard build?

      Can I create a filter that says something like this:
      Date (04/05/2024) is less than or equal to Age Date (Current Month-End).
      These have two different data types so I don't think BI will agree with the logic I'm trying to make happen.