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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
talkprem
Helper I
Helper I

Missing Entry Days Count Calculated Column in DAX

Hi,

I need a Ageing calculated column when the entry row is blank.

if row is blank of entry date side then give number of missing days
as I am trying to show row which don’t have data only
columns till pu_no are master data columns, from column Entry_date to PuNo are readings data
datediff between Entry_date previous row and calendar date current row might work
as it needs to reset once data comes in

Calendar date id T_no pu_noentry_date  SL id S NameOBBB Pr Name PuNo  Ageing
16/6/2024 10023 17 16/6/2024aaa 10023site1 er56 material1 17 0
17/6/2024 10023 17        1
18/6/2024  10023 17        2
19/6/2024 10023 17 19/6/2024 aaa 10023 site1 er56 material1 17 0
20/6/2024 10023 17        1
21/6/2024 10023 17 21/6/2024 aaa 10023 site1 er56 material1 17 0
22/6/2024 10023 17 22/6/2024 aaa 10023 site1 er56 material1 17 0
23/6/2024 10023 17        1
24/6/2024 10023 17 24/6/2024 aaa 10023 site1 er56 material1 17 

 

0

 

Any Help would be Appreciated.

@

1 ACCEPTED SOLUTION

Hi @talkprem ,

We have used below DAX expression and getting the aging column as 0,1,2 based on the number of days difference from Entry date.

 

Ageing =
VAR CurrentDate = Agingtable[Calendar date ]
VAR EntryDate = Agingtable[entry_date  ]

// Calculate the last non-blank entry_date before the current row
VAR LastEntryDate =
    CALCULATE(
        MAX(Agingtable[entry_date  ]),
        FILTER(
            ALL(Agingtable),
            Agingtable[Calendar date ] <= CurrentDate
                && NOT(ISBLANK(Agingtable[entry_date  ]))
        )
    )

// Calculate the Ageing based on the difference between current date and last non-blank entry_date
RETURN
    IF(
        ISBLANK(EntryDate),
        IF(
            NOT(ISBLANK(LastEntryDate)),
            DATEDIFF(LastEntryDate, CurrentDate, DAY),
            BLANK()
        ),
        0
    )

Please note to make sure you are also considering entry date in column expression, as per your screenshot it is some difference date field.

Result using expression is as follows,

SamInogic_0-1719231136591.png


Let us know if we are missing anything in the requirement.

Thanks!

 

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

View solution in original post

8 REPLIES 8
SamInogic
Super User
Super User

Hi @talkprem 

You can use below DAX query to create calculated column "Aging",

Ageing =
VAR CurrentDate = Agingtable[Calendar date ]
VAR EntryDate = Agingtable[entry_date  ]
RETURN
    IF(
        ISBLANK(EntryDate),
        DATEDIFF(
            CALCULATE(
                MAX(Agingtable[entry_date  ]),
                FILTER(
                    Agingtable,
                    Agingtable[Calendar date ]< CurrentDate
                        && NOT(ISBLANK(Agingtable[entry_date  ]))
                )
            ),
            CurrentDate,
            DAY
        ),
        0
    )

Result:

SamInogic_0-1718974867357.png

 

Thanks!

 

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/
Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

I tried but for me it gave outplut like this

talkprem_0-1718977292917.png

Hi @SamInogic Thanks for helping out but i am getting this output in my data.

there are few id columns which may need to added in the && clause. would EARLIER help?
If there was a way to get the last date of entry at the same row of calendar date the it would have helped on the solution.
there are s_id,T_id,P_id, date fields so the calculation should refresh at each new id fields.
the combination of these are unique.
Thank you in advance. and much respect for helping out.

Hi @talkprem ,

Just to confirm, do you changed the table name and column name as per your data structure. The issue shown in screenshot is due to mismatch of table name and column name.

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

Yes I have modified it as per my data structure, Please help

talkprem_0-1718979556570.png

 

Hi @talkprem ,

We have used below DAX expression and getting the aging column as 0,1,2 based on the number of days difference from Entry date.

 

Ageing =
VAR CurrentDate = Agingtable[Calendar date ]
VAR EntryDate = Agingtable[entry_date  ]

// Calculate the last non-blank entry_date before the current row
VAR LastEntryDate =
    CALCULATE(
        MAX(Agingtable[entry_date  ]),
        FILTER(
            ALL(Agingtable),
            Agingtable[Calendar date ] <= CurrentDate
                && NOT(ISBLANK(Agingtable[entry_date  ]))
        )
    )

// Calculate the Ageing based on the difference between current date and last non-blank entry_date
RETURN
    IF(
        ISBLANK(EntryDate),
        IF(
            NOT(ISBLANK(LastEntryDate)),
            DATEDIFF(LastEntryDate, CurrentDate, DAY),
            BLANK()
        ),
        0
    )

Please note to make sure you are also considering entry date in column expression, as per your screenshot it is some difference date field.

Result using expression is as follows,

SamInogic_0-1719231136591.png


Let us know if we are missing anything in the requirement.

Thanks!

 

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

The previous logic gave some aging increments but the 2nd one is giving 0 in my dataset. 

Thanks @SamInogic  for helping me ,
I Tried this solution but this does not calculate the actual gap between the entrydate and calendar date, this only shows 1 for each missing entry row. instead of showing 1 and 2 between 16/6 to 18/6 this is showing 1 and 1 for 16/6 to 18/6
can you please help me? maybe earlier function might be needed but i am unable to work it out.

Hi @talkprem ,

Then below DAX expression might help you to get the expected result,

Ageing =
VAR CurrentDate = Agingtable[Calendar date ]
VAR EntryDate = Agingtable[entry_date  ]

// Calculate the last non-blank entry_date before the current row
VAR LastEntryDate =
    CALCULATE(
        MAX(Agingtable[entry_date  ]),
        FILTER(
            ALL(Agingtable),
            Agingtable[Calendar date ] <= CurrentDate
                && NOT(ISBLANK(Agingtable[entry_date  ]))
        )
    )

// Calculate the Ageing based on the difference between current date and last non-blank entry_date
RETURN
    IF(
        ISBLANK(EntryDate),
        IF(
            NOT(ISBLANK(LastEntryDate)),
            DATEDIFF(LastEntryDate, CurrentDate, DAY),
            BLANK()
        ),
        0
    )

SamInogic_0-1718976791576.png


Thanks!

 

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/
Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Drop an email at crm@inogic.com
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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