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
BatsBeek
Frequent Visitor

Add a column which shows difference of rows in a previous column with max values

Hi,

 

Pretty new to PBI but having trouble using a simple excel formula in PBI.


I have the following data in PBI:

Max of TimeSinceNewMonthyear
19509201705
19595201706
19688201707
19793201708
19907201709
20030201710
20166201711
20210201712

 

The first column only shows max values as during a month multiple submissions are made to the database, however only the month end usage is of interest to calculate the total time the object was used during a month.

 

I want to add a column showing this usage per month by calculating the difference between the rows of the max TimeSinceNew column (here done in excel):

 

Max of TimeSinceNewMonthyearTime used per month
195092017050
1959520170686
1968820170793
19793201708105
19907201709114
20030201710123
20166201711136
2021020171244

Any ideas on how to do this in PBI?

2 REPLIES 2
v-sihou-msft
Employee
Employee

@BatsBeek

 

You can create a calculated column like below: 

 

Difference =
IF (
    CALCULATE (
        SUM ( Table1[Max of TimeSinceNew] ),
        FILTER ( Table1, Table1[Monthyear] = EARLIER ( Table1[Monthyear] ) - 1 )
    )
        = 0,
    0,
    Table1[Max of TimeSinceNew]
        - CALCULATE (
            SUM ( Table1[Max of TimeSinceNew] ),
            FILTER ( Table1, Table1[Monthyear] = EARLIER ( Table1[Monthyear] ) - 1 )
        )
)

1234.PNG

 

Regards,

 

 

Hi @v-sihou-msft,

 

Thanks, this formula seems to come close, however PBI says the column 'Max of TimeSinceNew' cannot be found or may not be used in the table. The column TimeSinceNew has multiple values for each Monthyear, but as I am only intereseted in the final usage at the end of the month I use the Max filter. 

 

Is there a way to create the column showing the differences between the Max values of TimeSinceNew per Monthyear?

 

Best regards

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.