Forum Discussion

anshenterprice's avatar
4 years ago
Solved

split rows into column on date column

Hi Team,

 

We have large amount of data on each date . below is just sample source data.

ScriptNameValueDate
Tata Motors2505/3/2022
Relience14005/3/2022
Infosys15005/3/2022
Bajaj20005/3/2022
Dell1405/3/2022
Tata Motors2605/2/2022
Relience15005/2/2022
Infosys13005/2/2022
Bajaj20105/2/2022
Dell1455/2/2022
Tata Motors2755/1/2022
Relience14505/1/2022
Infosys12005/1/2022
Bajaj20305/1/2022
Dell1355/1/2022
Tata Motors2804/31/2022
Relience15054/31/2022
Infosys16004/31/2022
Bajaj21004/31/2022
Dell1484/31/2022


i want only today date(Today) values and yesterday(t-1) and day befor yesterday(T-2) and difference today and t-2 

output:-

ScripnameT-2T-1TodayDifference Today and T-2
Bajaj20302010200030
Dell135145140-5
Infosys120013001500-300
Relience14501500140050
Tata Motors27526025025
  • Hi, anshenterprice 

     

    Please try the following methods.

    Measure:

    Today =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            [Date] = MAX ( 'Table'[Date] )
                && [ScriptName] = SELECTEDVALUE ( 'Table'[ScriptName] )
        )
    )
    
    T-1 =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            [Date]
                = MAX ( 'Table'[Date] ) - 1
                && [ScriptName] = SELECTEDVALUE ( 'Table'[ScriptName] )
        )
    )
    
    T-2 =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            [Date]
                = MAX ( 'Table'[Date] ) - 2
                && [ScriptName] = SELECTEDVALUE ( 'Table'[ScriptName] )
        )
    )
    
    Difference Today and T-2 = [T-2]-[Today]

    Is this the result you were hoping for?

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

4 Replies

  • I changed some of you data to todays date for illustration purposes



    you can use Today() - 1 on your T1 measure and so on

     

    • anshenterprice's avatar
      anshenterprice
      Helper I

      Thank you NickolajJessen 

      It should not be always today's date may be rather we can use max date . i tried but getting error
      and also please help on the lastcolumn ie. Difference Today and T-2

       

       

      • NickolajJessen's avatar
        NickolajJessen
        Solution Sage

        Can you elaborate what is not working and include screenshots of what you tried - measures and such

  • v-zhangti's avatar
    v-zhangti
    Community Support

    Hi, anshenterprice 

     

    Please try the following methods.

    Measure:

    Today =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            [Date] = MAX ( 'Table'[Date] )
                && [ScriptName] = SELECTEDVALUE ( 'Table'[ScriptName] )
        )
    )
    
    T-1 =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            [Date]
                = MAX ( 'Table'[Date] ) - 1
                && [ScriptName] = SELECTEDVALUE ( 'Table'[ScriptName] )
        )
    )
    
    T-2 =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALL ( 'Table' ),
            [Date]
                = MAX ( 'Table'[Date] ) - 2
                && [ScriptName] = SELECTEDVALUE ( 'Table'[ScriptName] )
        )
    )
    
    Difference Today and T-2 = [T-2]-[Today]

    Is this the result you were hoping for?

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.