Forum Discussion

puserp's avatar
puserp
Regular Visitor
2 years ago

defference between two named expressions

Thanks to Anonymous and bhanu_gautam I finally got that working :

SUMMARIZECOLUMNS (
'TABLE 1'[Dim1], [...]
'TABLE 1'[Dim2],
'TABLE 1'[Dim3],
"Measure1 t1", CALCULATE ( SUM ( 'TABLE 1'[Measure1] ), 'TABLE 1'[Date] = "t1" ),
"Measure 2 t1", CALCULATE ( SUM ( 'TABLE 1'[Measure2] ), 'TABLE 1'[Date] = "t1" ),
"Measure1 t2", CALCULATE ( SUM ( 'TABLE 1'[Measure1] ), 'TABLE 1'[Date] = "t2" ),
"Measure 2 t2", CALCULATE ( SUM ( 'TABLE 1'[Measure2] ), 'TABLE 1'[Date] = "t2" )
)

Now, I'd like to to return difference between Measure1 at t2 - t1 ?

What is the syntax to call something like (adding the following line to the query above doesn't work):

DeltaT2T1 = [Measure1 t2] - [Measure1 t1]

Should I do something like :

VAR Measure1 t1 = CALCULATE ( SUM ( 'TABLE 1'[Measure1] ), 'TABLE 1'[Date] = "t1" ),
VAR Measure1 t2" = CALCULATE ( SUM ( 'TABLE 1'[Measure1] ), 'TABLE 1'[Date] = "t2" ),
SUMMARIZECOLUMNS (
'TABLE 1'[Dim1], [...]
"Measure1 t1", [Measure1 t1],
"Measure1 t2", [Measure1 t2],
"Delta", [Measure1 t2] - [Measure1 t1]
)

or is there another / better way ?

3 Replies

    • puserp's avatar
      puserp
      Regular Visitor

      Thanks 😉 , I still have a new question in this post 😉

  • puserp's avatar
    puserp
    Regular Visitor

    I voted mysel a RTFM  : "Columns in table variables cannot be referenced via TableName[ColumnName] syntax"

    So what I wanted to do just can't be done.
    The idea I had with measure would probably do the trick... but thoses measures can't use outside VAR which would be the case in my problem.

    I guess I have to find another way