Forum Discussion

abc_777's avatar
abc_777
Solution Specialist
4 years ago
Solved

hi

Hi,

could some one help me to calculate the following using DAX

 

Earned PointReedeem PointPoint Balance
200
300
528
7015
2413

 

thanks

  • Hi abc_777 
    Here is a sample file with the solutuion https://www.dropbox.com/t/cvHrJVgWHiu6ZPaf

    First you need to add index column (if you have unique date or date/time column it also works just fine)

    Then use the following code to create a new calculated column (let me know if you need measure instead)

    Point Balance = 
    VAR CurrentIndex = Data[Index]
    VAR TableOnAndBefore = FILTER ( Data, Data[Index] <= CurrentIndex )
    VAR EarnedPoints = SUMX ( TableOnAndBefore, Data[Earned Point] )
    VAR RedeemedPoints = SUMX ( TableOnAndBefore, Data[Reedeem Point] )
    RETURN
        IF ( 
            RedeemedPoints = 0,
            0,
            EarnedPoints - RedeemedPoints
        )

3 Replies

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi abc_777 
    Here is a sample file with the solutuion https://www.dropbox.com/t/cvHrJVgWHiu6ZPaf

    First you need to add index column (if you have unique date or date/time column it also works just fine)

    Then use the following code to create a new calculated column (let me know if you need measure instead)

    Point Balance = 
    VAR CurrentIndex = Data[Index]
    VAR TableOnAndBefore = FILTER ( Data, Data[Index] <= CurrentIndex )
    VAR EarnedPoints = SUMX ( TableOnAndBefore, Data[Earned Point] )
    VAR RedeemedPoints = SUMX ( TableOnAndBefore, Data[Reedeem Point] )
    RETURN
        IF ( 
            RedeemedPoints = 0,
            0,
            EarnedPoints - RedeemedPoints
        )