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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
jcastr02
Post Prodigy
Post Prodigy

Date calculation with IF

I'd like to be able to create a calculated column or measure that would tell me the "Next Audit Date" based on the last audit date and the tier level.  Note that the "last audit date" is on another table.    Example, tier 1 next audit date is 365 days after last audit date, tier 2 is 2 years after, tier 3 is 3 years after etc.  

 

tier.png

 

 

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @jcastr02 ,

 

Is the last audit data the smallest date in each group of the audit data field in the compliance table? Then get the next audit date based on the grade. I did the following test:

Last_audit Name = 
CALCULATE (
    MIN ( 'Compliance table'[Audit Name] ),
    FILTER (
        ALL ( 'Compliance table' ),
        'Compliance table'[Document Name] = 'Document Table'[Document Name]
    )
)
next_audit Name = 'Document Table'[Last_audit Name].[Date]+'Document Table'[Tier level]*365

There is no need to establish any relationship between the other two tables.

v-henryk-mstf_0-1623728309418.png


If i misunderstand what you mean, can you further clarify your needs, such as a screenshot of the desired result. I will answer you as soon as possible. Looking forward to your reply.

Best Regards,
Henry

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-henryk-mstf
Community Support
Community Support

Hi @jcastr02 ,

 

Is the last audit data the smallest date in each group of the audit data field in the compliance table? Then get the next audit date based on the grade. I did the following test:

Last_audit Name = 
CALCULATE (
    MIN ( 'Compliance table'[Audit Name] ),
    FILTER (
        ALL ( 'Compliance table' ),
        'Compliance table'[Document Name] = 'Document Table'[Document Name]
    )
)
next_audit Name = 'Document Table'[Last_audit Name].[Date]+'Document Table'[Tier level]*365

There is no need to establish any relationship between the other two tables.

v-henryk-mstf_0-1623728309418.png


If i misunderstand what you mean, can you further clarify your needs, such as a screenshot of the desired result. I will answer you as soon as possible. Looking forward to your reply.

Best Regards,
Henry

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

amitchandak
Super User
Super User

@jcastr02 , need more data, but you have try like

new column in table 1

minx(filter(Table2, Table1[tire level] =Table2[tire level] && Table1[last Audit date] <Table2[next audit date]),Table2[next audit date])

@amitchandak    I have two table like below with the document Name being the unique id.  Tier 1 - Audit every 1 year, Tier 2 - Audit every 2 years, and Tier 3 Audit every 3 years.  Based on the last audit, seeking to find the next audit date for a document.    (sorry it wouldn't let me add table below with data, so include a screen capture)

 

Table Example.png

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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