Forum Discussion
IN vs Out per day
- 8 years ago
Hi Alex,
First in the edit query unpivot Date IN & Date OUT column, which will result in the below table:
Then make a summarised columns which only contains date:
Date = SUMMARIZE(Table1,Table1[Value])
Link this table and the main table on value (Date column)
Make two columns for date in & out count:
IN = CALCULATE(COUNT(Table1[Attribute]),Table1[Attribute]="DATE In")
OUT = CALCULATE(COUNT(Table1[Attribute]),Table1[Attribute]="DATE OUT")
Finally create two measures for running total and then take the difference for the last column.
IN running total in Value =
CALCULATE(
SUM('Date'[IN]),
FILTER(
ALLSELECTED('Date'[Value]),
ISONORAFTER('Date'[Value], MAX('Date'[Value]), DESC)
)
)OUT running total in Value =
CALCULATE(
SUM('Date'[OUT]),
FILTER(
ALLSELECTED('Date'[Value]),
ISONORAFTER('Date'[Value], MAX('Date'[Value]), DESC)
)
)Difference = [OUT running total in Value]-[IN running total in Value]
Regards,
Saurabh Kedia
Please tell me if you need more details.
thank you very much in advance.
Hi Alex,
First in the edit query unpivot Date IN & Date OUT column, which will result in the below table:
Then make a summarised columns which only contains date:
Date = SUMMARIZE(Table1,Table1[Value])
Link this table and the main table on value (Date column)
Make two columns for date in & out count:
IN = CALCULATE(COUNT(Table1[Attribute]),Table1[Attribute]="DATE In")
OUT = CALCULATE(COUNT(Table1[Attribute]),Table1[Attribute]="DATE OUT")
Finally create two measures for running total and then take the difference for the last column.
IN running total in Value =
CALCULATE(
SUM('Date'[IN]),
FILTER(
ALLSELECTED('Date'[Value]),
ISONORAFTER('Date'[Value], MAX('Date'[Value]), DESC)
)
)
OUT running total in Value =
CALCULATE(
SUM('Date'[OUT]),
FILTER(
ALLSELECTED('Date'[Value]),
ISONORAFTER('Date'[Value], MAX('Date'[Value]), DESC)
)
)
Difference = [OUT running total in Value]-[IN running total in Value]
Regards,
Saurabh Kedia