Forum Discussion

DanyyalK's avatar
DanyyalK
Regular Visitor
6 years ago
Solved

Incorrect Value with Date Calculation

Hey everyone,

 

 

I'm using PowerBI to create an aging report. I use two measures, one that calculates aging as of a given date, and another measure that calculates aging based on the last day of the last month. When I run both these measures giving the same date, the value is drastically different. Am I doing something wrong?

 

>120 Days =
VAR LastDay= MAX(KeyDate[Date]) //should return the selected date
RETURN
SUMX(
FILTER(
'Debtors Aging Open Items Total Dump (2)',
'Debtors Aging Open Items Total Dump (2)'[Net due date.Net due date Level 01]<=LastDay-121 && 'Debtors Aging Open Items Total Dump (2)'[Item Status.Item Status Level 01] = "O"
),
'Debtors Aging Open Items Total Dump (2)'[Debit/Credit Amount]
)
 
This is the measure that calculates based on the last date of last month:
 
(MON-1) >120 Days =
VAR LastDay= EOMONTH(MAX(KeyDate[Date]),-1) //should return last date of last month
RETURN
SUMX(
FILTER(
'Debtors Aging Open Items Total Dump (2)',
'Debtors Aging Open Items Total Dump (2)'[Net due date.Net due date Level 01]<=LastDay-121 && 'Debtors Aging Open Items Total Dump (2)'[Item Status.Item Status Level 01] = "O"
),
'Debtors Aging Open Items Total Dump (2)'[Debit/Credit Amount]
)
 
 
 
  • If you give them the same date, the first measure will evaluate variable LastDay as that date, while the second measure will evaluate it as the date of the end of the previous month. So if the context of KeyDate[Date] only contains 15/01/2020, then the first measure will have VAR LastDay =  15/01/2020 and the second measure will have VAR LastDay =  31-12-2019.

    In another case, if the context of KeyDate[Date] only contains 30/11/2019, then the first measure will have VAR LastDay = 30/11/2019 and the second measure will have VAR LastDay =  31-10-2019. (becasue of the -1 in your VAR statement).

     

    Kind regards

    Djerro123

    -------------------------------

    If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

    Keep those thumbs up coming! 🙂

1 Reply

  • JarroVGIT's avatar
    JarroVGIT
    Resident Rockstar

    If you give them the same date, the first measure will evaluate variable LastDay as that date, while the second measure will evaluate it as the date of the end of the previous month. So if the context of KeyDate[Date] only contains 15/01/2020, then the first measure will have VAR LastDay =  15/01/2020 and the second measure will have VAR LastDay =  31-12-2019.

    In another case, if the context of KeyDate[Date] only contains 30/11/2019, then the first measure will have VAR LastDay = 30/11/2019 and the second measure will have VAR LastDay =  31-10-2019. (becasue of the -1 in your VAR statement).

     

    Kind regards

    Djerro123

    -------------------------------

    If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

    Keep those thumbs up coming! 🙂