March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi al,
I know this question has been asked before, but I tried them all and wasn't able to compete. Sorry!
I've got the below table (4 colums) within Power BI (just created a table in Excel to edit values). I would like to calculate the difference between values in column "Kilometers".
The calculation should only be applied for rows with the same value for column "Reference", so I guess we need to calculate the difference between a row and a row where [Index] = ([Index] -1) ?
Anybody got any tips on the DAX or Power Query code to be applied? I've created a column "Expected result" in Excel, just to clarify things.
Thanks in advance!
Solved! Go to Solution.
try this
Column = VAR Index = 'Table'[Index] VAR Reference = 'Table'[Reference] VAR PrevKilometers = CALCULATE ( FIRSTNONBLANK ( 'Table'[Kilometers], TRUE () ), FILTER ( 'Table', 'Table'[Index] = Index - 1 && 'Table'[Reference] = Reference ) ) RETURN IF ( ISBLANK ( PrevKilometers ), BLANK (), 'Table'[Kilometers] - PrevKilometers )
try this
Column = VAR Index = 'Table'[Index] VAR Reference = 'Table'[Reference] VAR PrevKilometers = CALCULATE ( FIRSTNONBLANK ( 'Table'[Kilometers], TRUE () ), FILTER ( 'Table', 'Table'[Index] = Index - 1 && 'Table'[Reference] = Reference ) ) RETURN IF ( ISBLANK ( PrevKilometers ), BLANK (), 'Table'[Kilometers] - PrevKilometers )
Hello Mr. Stachu,
I tried the above formula and it returned the incorrect values. All the valules in the column are taking the first value as a reference. Please find the attached image for the reference.
based on the formula provided below i have done on my data set but error is coming. kinldy guide me urgently.
I want to know the incremental number of column
Death Cases, confirmed Cases,Recovered CAses, Active Cases.
@usmanaziz you try to create a measure, the code you posted will only work as a calculated column
How can I adjust your formula to include data also as a criteria ?
i.e.,compare the values between current timestamp and previous time stamp,say 17-08-2019,10:25 P.M and 17-08-2019,10:30 P.M.
I have an ID Field and the glucose values,I should be capable of comparing the glucose_value,every now and then to indicate the episodes or spike in glucose level.
Thanks
the ID can be the same for multiple dates?
if yes then the difference in glucose for a given ID should be something like this:
Column = VAR __ID = 'Table'[ID] VAR __DateTime = 'Table'[DateTime] VAR __PreviousDateTime = CALCULATE ( MAX ( 'Table'[DateTime] ), FILTER ( 'Table', 'Table'[ID] = __ID && 'Table'[DateTime] < __DateTime) ) VAR __PreviousGlucose = CALCULATE ( MAX ( 'Table'[Glucose] ), FILTER ( 'Table', 'Table'[ID] = __ID && 'Table'[DateTime] = __PreviousDateTime) ) RETURN IF ( ISBLANK ( __PreviousDateTime ), BLANK (), 'Table'[Glucose] - __PreviousGlucose )
Hi @Wickin
The image attached is not visible.
It would be great if you provide the Excel with dummy data.
Regards,
Suguna.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
86 | |
76 | |
57 | |
52 |
User | Count |
---|---|
201 | |
137 | |
108 | |
73 | |
68 |