Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Add a new filtered colum

Hi BI Community,

I have Table#1

IDProduction       IDProcess       TimeShiftBegin                TimeShiftEnd

1000                           1          2018-04-19 06:45:00       2018-04-19 08:45:00

1001                           2          2018-04-19 06:45:00       2018-04-19 08:45:00

1002                           3          2018-04-19 06:45:00       2018-04-19 08:45:00

1003                           1          2018-04-19 09:00:00       2018-04-19 11:00:00

1004                           2          2018-04-19 09:00:00       2018-04-19 11:00:00

....

 

And Table#2

ScalingID       Volume         Lenght              ScaledOn

22000                 45                 8            2018-04-19 06:45:18

22001                 45                 10          2018-04-19 06:45:43

22002                 30                 8            2018-04-19 06:46:04

 

In Table#2 I want to had Table#1[IDProduction] when ScaledOn date is between Table#1[TimeShiftBegin] and Table#1[TimeShiftEnd] and when Table#1[IDProcess] =2. Like this:

 

ScalingID       Volume         Lenght              ScaledOn                  IDProduction

22000                 45                 8            2018-04-19 06:45:18             1001

22001                 45                 10          2018-04-19 06:45:43             1001

22002                 30                 8            2018-04-19 06:46:04             1001

....

22223                 50                 9            2018-04-19 09:01:22             1004

22224                 35                 10          2018-04-19 09:01:54             1004

22225                 30                 8            2018-04-19 09:02:14             1004

          

Note that this 2 tables have nothing in common.

Thanks for your help!

FRG

  • Anonymous's avatar
    Anonymous
    8 years ago

    Hi v-xjiin-msft,

    I find something and it seem to work.

    FilteredIDProduction2 = CALCULATE(

                                                      MAXA(Table#1[idProduction]);

                                                      FILTER(

                                                             Table#1;Table#1[TimeShiftBegin] <= (Table#2[ScaledOn]) &&

                                                              Table#1[TimeShiftEnd] >= (Table#2[ScaledOn]) &&

                                                               Table#1[idProcess] = 2

                                                                            )

                                             )

     

    Thanks again

3 Replies

  • Hi Anonymous,

     

    Try this measure:

     

    Filtered IDProduction =
    CALCULATE (
        MAX ( 'Table#1'[IDProduction] ),
        FILTER (
            'Table#1',
            'Table#1'[TimeShiftBegin] <= MAX ( 'Table#2'[ScaledOn] )
                && 'Table#1'[TimeShiftEnd] >= MAX ( 'Table#2'[ScaledOn] )
                && 'Table#1'[IDProcess] = 2
        )
    )

     

    Thanks,
    Xi Jin.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi v-xjiin-msft,

      With this measure I get the same (the last) IDProduction (where IDProcess =2) for all rows in Table#2.

      Thanks

      FRG

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi v-xjiin-msft,

        I find something and it seem to work.

        FilteredIDProduction2 = CALCULATE(

                                                          MAXA(Table#1[idProduction]);

                                                          FILTER(

                                                                 Table#1;Table#1[TimeShiftBegin] <= (Table#2[ScaledOn]) &&

                                                                  Table#1[TimeShiftEnd] >= (Table#2[ScaledOn]) &&

                                                                   Table#1[idProcess] = 2

                                                                                )

                                                 )

         

        Thanks again