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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
IvanS
Helper V
Helper V

Day over day change with specific conditions

Hi guys,

 

I have Power Automate flow that is storing actual data from Power BI dataset on daily basis and saving it into Excel table.

 

The format of table is following with desired calculation in the last column:

MailboxFolder PathNr. of EmailsUpload DateDaily Change (desired)
ABC@company.com\Inbox\In Progress2026.3.20240 (as there is no entry with previous date)
XYZ@company.com\Inbox\1026.3.20240 (as there is no entry with previous date)
XYZ@company.com\Inbox\In Progress326.3.20240 (as there is no entry with previous date)
ABC@company.com\Inbox\In Progress2527.3.20245
XYZ@company.com\Inbox\827.3.2024-2
XYZ@company.com\Inbox\In Progress627.3.20243

 

The calculation should take into consideration the Mailbox and Folder Path and show the daily change for this unique combination.

 

I tried with something like below, but the calculation is not working.

 

VAR _previousday = MAX(Upload date) - 1

VAR _currentday = MAX(Upload date)

VAR _previousdayemails = 
CALCULATE(SUM(Nr. of Emails), Upload date = MAX(Upload date) - 1 )

VAR _currentdayemails =
CALCULATE(SUM(Nr. of Emails), Upload date = MAX(Upload date) )

RETURN
_currentdayemails - _previousdayemails

 

 

Thank you for any help!


IvanS

1 ACCEPTED SOLUTION
v-yilong-msft
Community Support
Community Support

Hi @IvanS ,

I create a table as you mentioned.

vyilongmsft_0-1711596698251.png

Then I create a calculated column to satisfy your requirements. Here is the DAX code.

 

Daily Change = 
VAR _previousDate =
    CALCULATE (
        MAX ( 'Table'[Upload Date] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Upload Date] < EARLIER ( 'Table'[Upload Date] )
        )
    )
VAR _previousNr =
    CALCULATE (
        MAX ( 'Table'[Nr. of Emails] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Mailbox] = EARLIER ( 'Table'[Mailbox] )
                && 'Table'[Folder Path] = EARLIER ( 'Table'[Folder Path] )
                && 'Table'[Upload Date] = _previousDate
        )
    )
RETURN
    IF ( _previousNr <> BLANK (), 'Table'[Nr. of Emails] - _previousNr, 0 )

 

Finally you will get what you want.

vyilongmsft_1-1711596871810.png

 

 

 

Best Regards

Yilong Zhou

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

1 REPLY 1
v-yilong-msft
Community Support
Community Support

Hi @IvanS ,

I create a table as you mentioned.

vyilongmsft_0-1711596698251.png

Then I create a calculated column to satisfy your requirements. Here is the DAX code.

 

Daily Change = 
VAR _previousDate =
    CALCULATE (
        MAX ( 'Table'[Upload Date] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Upload Date] < EARLIER ( 'Table'[Upload Date] )
        )
    )
VAR _previousNr =
    CALCULATE (
        MAX ( 'Table'[Nr. of Emails] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Mailbox] = EARLIER ( 'Table'[Mailbox] )
                && 'Table'[Folder Path] = EARLIER ( 'Table'[Folder Path] )
                && 'Table'[Upload Date] = _previousDate
        )
    )
RETURN
    IF ( _previousNr <> BLANK (), 'Table'[Nr. of Emails] - _previousNr, 0 )

 

Finally you will get what you want.

vyilongmsft_1-1711596871810.png

 

 

 

Best Regards

Yilong Zhou

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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