Forum Discussion

ALEX13's avatar
ALEX13
Icon for Helper I rankHelper I
8 years ago
Solved

IN vs Out per day

Hi community, I have the following challenge:   With a dataset like this:   Aviso Date IN Date Out Texto código del problema 305050015 02/03/2018 02/03/2018 Plataforma telefónica ...
  • saurabh_kedia_'s avatar
    saurabh_kedia_
    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