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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Can anybody help me implement this logic in DAX? We are using direct query.

x, y, z are three different fields/columns with values x1, x2...; y1, y2...; and so on.

 

in case of x we just know "x1" and we need to find x2, x3, x4... in following manner:
x2= x1+y1-z1
x3= x2+y2-z2
and so on

 

all y and z field values are given but in case of x we just know x1.

How can we apply this in Dax to find x2, x3,....?

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 

i assume that you have a unique date or index column. Otherwise you nee to create one. 

X =
VAR X1 = 1 --inset the initial value 
VAR CurrentIndex = TablName[Index]
VAR TableBefore =
    FILTER ( TablName, TablName[Index] < CurrentIndex )
VAR Y =
    SUMX ( TableBefore, TablName[Y] )
VAR Z =
    SUMX ( TableBefore, TablName[Z] )
RETURN
    X1 + Y - Z



View solution in original post

5 REPLIES 5
Anonymous
Not applicable

x, y, z are three different fields/columns with values x1, x2...; y1, y2...; and so on.

 

in case of x we just know "x1" and we need to find x2, x3, x4... in following manner:
x2= x1+y1-z1
x3= x2+y2-z2
and so on

 

all y and z field values are given but in case of x we just know x1.

How can we apply this in Dax to find x2, x3,....?

 

 

@tamerj1 

tamerj1
Super User
Super User

Hi @Anonymous 

i assume that you have a unique date or index column. Otherwise you nee to create one. 

X =
VAR X1 = 1 --inset the initial value 
VAR CurrentIndex = TablName[Index]
VAR TableBefore =
    FILTER ( TablName, TablName[Index] < CurrentIndex )
VAR Y =
    SUMX ( TableBefore, TablName[Y] )
VAR Z =
    SUMX ( TableBefore, TablName[Z] )
RETURN
    X1 + Y - Z



Anonymous
Not applicable

How would these work if you can explain me? 

SUMX ( TableBefore, TablName[Y] )
SUMX ( TableBefore, TablName[Z] )

 

Hi @Anonymous 
Simple mathmatics

x2= x1+y1-z1
x3= x2+y2-z2 = x1+y1-z1+y2-z2 = x1 + (y1+y2) - (z1+z2) = x1 + SUMX (Y) - SUMX (Z)

Helpful resources

Announcements
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.

Top Solution Authors