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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
kballar1
Helper I
Helper I

Aging Bucket With One Date Column

Hello,

 

I am creating a dashboard that needs to meet these requirements:

Visuals for both Receivables and Payables showing individual buckets. Sorting should be based on age: 

Current

0-30

31-60

61-90

91-120

 

Attached is a snippet is the only data I have to work with. Dates range from Feb 2024-May 2024.data.png I keep creating an aging bucket using this measure but it only shows up the 0-30 day bucket. Please help.

Age_Bucket = 
VAR _Age = DATEDIFF('Table'Due Date,'Table'[Due Date], DAY)
VAR _Result = 
SWITCH(
    TRUE(),
    _Age < 30, "0-30 days",
    _Age >= 31 && _Age < 60, "31-60 days",
    _Age >= 61 && _Age < 90, "61-90 days",
    _Age >= 91, "120+ days"
)
Return
_Result   

 

3 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

Age_Bucket = 
VAR _Age = DATEDIFF('Table'[Due Date], TODAY(), DAY)
RETURN SWITCH(
    TRUE(),
    _Age < 30, "0-29 days",
    _Age < 60, "31-59 days",
    _Age < 90, "60-89 days",
    "90+ days"
)

View solution in original post

aduguid
Resolver III
Resolver III

aduguid_0-1714360085681.png

aduguid_2-1714360383496.png

 

Calendar Aging = 
VAR _today_date = TODAY()
VAR _min_date =   CALCULATE(MIN(YourTable[Due_Date]))

VAR _result = 
UNION (
      ADDCOLUMNS (CALENDAR ( _today_date - 30, _today_date - 1),    "Aging Days", "0 to 30",   "Aging Days Order", 1)
    , ADDCOLUMNS (CALENDAR ( _today_date - 60, _today_date - 31 ),  "Aging Days", "31 to 60",  "Aging Days Order", 2)
    , ADDCOLUMNS (CALENDAR ( _today_date - 90, _today_date - 61 ),  "Aging Days", "61 to 90",  "Aging Days Order", 3)
    , ADDCOLUMNS (CALENDAR ( _today_date - 120, _today_date - 91 ), "Aging Days", "91 to 120", "Aging Days Order", 4)
    , ADDCOLUMNS (CALENDAR ( _min_date, _today_date - 121),         "Aging Days", "120+",      "Aging Days Order", 5)
)

RETURN
_result

 

View solution in original post

v-xuxinyi-msft
Community Support
Community Support

Hi @kballar1 

 

Thanks for the reply from @lbendlin  and @aduguid , please allow me to provide another insight:

 

Do you want to compare the maximum date in a table with the date of each row? If so, try the following formula.

 

Age_Bucket = 
VAR _MAX = CALCULATE(MAX([Due Date]), ALL('Table'))
VAR _Age = DATEDIFF(MAX([Due Date]), _MAX, DAY)
VAR _Result = 
SWITCH(
    TRUE(),
    _Age < 30, "0-30 days",
    _Age >= 31 && _Age < 60, "31-60 days",
    _Age >= 61 && _Age < 90, "61-90 days",
    _Age >= 91, "120+ days"
)
Return
_Result

 

I added the dates through May to your screenshot.

vxuxinyimsft_0-1714371818701.png

 

Result:

vxuxinyimsft_1-1714371872629.png

 

If I've misunderstood you, please feel free to let me know.

 

Best Regards,
Yulia Xu

 

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
v-xuxinyi-msft
Community Support
Community Support

Hi @kballar1 

 

Thanks for the reply from @lbendlin  and @aduguid , please allow me to provide another insight:

 

Do you want to compare the maximum date in a table with the date of each row? If so, try the following formula.

 

Age_Bucket = 
VAR _MAX = CALCULATE(MAX([Due Date]), ALL('Table'))
VAR _Age = DATEDIFF(MAX([Due Date]), _MAX, DAY)
VAR _Result = 
SWITCH(
    TRUE(),
    _Age < 30, "0-30 days",
    _Age >= 31 && _Age < 60, "31-60 days",
    _Age >= 61 && _Age < 90, "61-90 days",
    _Age >= 91, "120+ days"
)
Return
_Result

 

I added the dates through May to your screenshot.

vxuxinyimsft_0-1714371818701.png

 

Result:

vxuxinyimsft_1-1714371872629.png

 

If I've misunderstood you, please feel free to let me know.

 

Best Regards,
Yulia Xu

 

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

aduguid
Resolver III
Resolver III

aduguid_0-1714360085681.png

aduguid_2-1714360383496.png

 

Calendar Aging = 
VAR _today_date = TODAY()
VAR _min_date =   CALCULATE(MIN(YourTable[Due_Date]))

VAR _result = 
UNION (
      ADDCOLUMNS (CALENDAR ( _today_date - 30, _today_date - 1),    "Aging Days", "0 to 30",   "Aging Days Order", 1)
    , ADDCOLUMNS (CALENDAR ( _today_date - 60, _today_date - 31 ),  "Aging Days", "31 to 60",  "Aging Days Order", 2)
    , ADDCOLUMNS (CALENDAR ( _today_date - 90, _today_date - 61 ),  "Aging Days", "61 to 90",  "Aging Days Order", 3)
    , ADDCOLUMNS (CALENDAR ( _today_date - 120, _today_date - 91 ), "Aging Days", "91 to 120", "Aging Days Order", 4)
    , ADDCOLUMNS (CALENDAR ( _min_date, _today_date - 121),         "Aging Days", "120+",      "Aging Days Order", 5)
)

RETURN
_result

 

lbendlin
Super User
Super User

Age_Bucket = 
VAR _Age = DATEDIFF('Table'[Due Date], TODAY(), DAY)
RETURN SWITCH(
    TRUE(),
    _Age < 30, "0-29 days",
    _Age < 60, "31-59 days",
    _Age < 90, "60-89 days",
    "90+ days"
)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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