📚
Tech-Posts
  • README
  • Kafka + Maxwell
  • Kafka
  • Docker
  • MySQL connection via SSH
  • Python
    • Django
    • PyCharm+Docker Dev
    • Pip Tools
    • python project with local packages
  • PHP
    • PhpStorm+Docker Dev
  • Cassandra
  • AWS
    • Cheat Sheet
    • Lambda with Kinesis Event Source Mapping
  • AWS DMS
  • Lambda demo function to produce to Kinesis
  • Deploy a static web page with protection of specific static resources on AWS S3
  • Data Engineer
    • Move Salesforce Files out using Pentaho DI
  • A Pentaho DI Project Readme
  • PowerBI
    • Power BI refer to previous row
Powered by GitBook
On this page
  • Background
  • Step
  • References

Was this helpful?

  1. PowerBI

Power BI refer to previous row

PreviousA Pentaho DI Project Readme

Last updated 3 years ago

Was this helpful?

Background

sample data

Formula is like:

result = 
if [previous row exists]: 
    (last(target) - first(target))/11 + <previous row value> 
else: 
    first(target)

In PowerBI we cannot refer to self (e.g. previous row same column), but can refer to previous row another column.

So we can make kind of math transformation:

row0 = 1.7
row1 = (2.15 - 1.7)/11  + 1.7
row2 = (2.15 - 1.7)/11 + row1 =  (2.15 - 1.7)/11 * 2 + 1.7
row3 = (2.15 - 1.7)/11 + row2 = (2.15 - 1.7)/11 * 3 + 1.7
...

The transformed formula:

result = 
(last(target) - first(target))/11 * <index of row> + first(target)

Step

  • Load Data

  • Add Index Column

  • Add Custom Column 'result', make formula:

( List.Last(#"Added Index" [target])  - List.First(#"Added Index" [target]))/11 * #"Added Index" {[Index]}[Index] + List.First(#"Added Index" [target])

the List.Last can be replace by List.Max, and List.First can be replaced by Lits.Min regard of context.

  • Final Result:

References

thRe: Find value of Previous Row in same column
Logo