Forum Discussion

Prabunathan's avatar
Prabunathan
Frequent Visitor
8 years ago
Solved

Dynamic Filtering

Hi,

 

I have a situaiton, where in i have to extract the trasactions which happened due to a specific promotion ( example a Gift Voucher Promotion ). From the millions of transactions, i have to get the trasactions filtered which have a combination of " Item " + " Gift Voucher ".

 

The following example better illustrates the requirement.

 

DateTransaction IdItem CodeItem DescriptionQty
01-Dec-17A001PH001Asus Phone X0013
01-Dec-17A001GV100Gif Voucher 1003
04-Dec-17A002PH001Asus Phone X0016
03-Dec-17A003PH001Asus Phone X0014
03-Dec-17A003GV100Gif Voucher 1004
04-Dec-17A004WM001Washing Machine B0018
02-Dec-17A005WM001Washing Machine B0019
02-Dec-17A005GV100Gif Voucher 1009
 EXAMPLE  1    
FILTER    
# of PH001 Units Sold under GV Promotion ( i.e Total of Qty where a transaction ID contains PH001 and GV100 line items ) 
     
RESULT Transaction IDQty 
  A0013 
  A0034 
 EXAMPLE 2    
FILTER    
# of WM001 Sold under GV Promotion ( i.e Total of Qty where a transaction ID contains WM001 + GV100 line items ) 
     
RESULT Transaction IDQty 
  A0059 

 

I need to select the " Item Code " by a filter to get the extract of Trasaction ID's where the sales Criterea is Item + Gift Voucher.

 

Thanks in advance for your guidance.

 

Prabunathn

  • stretcharm's avatar
    stretcharm
    8 years ago

    Apologies I didn't read the examples.

    Is the Item code a load filter or a Slicer on all the data?

     

     If a slicer then add a measure like this and Filter by the slicer for Item code and  in the filter pane HasGV>0

    HasGV = 
    VAR GV = "GV100"
    RETURN
        CALCULATE (
            COUNT ( Trans[Transaction Id] ),
            FILTER (
                ALL ( Trans ),
                Trans[Transaction Id] = MAX ( Trans[Transaction Id] )
                    && Trans[Item Code] = GV
            )
        )

11 Replies

  • stretcharm's avatar
    stretcharm
    Memorable Member

     

    Is the data in Columns? If so can you just filter the Description that Starts with Gift voucher

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("vZJda8IwFIb/ykt3szEdra37uOywc0ILndYPEC9CG2dAEzCRsX+/NLG6QutgjEHLgffkOec9J1kuHdfrDmje9R6cjhO6rqdD+mpjKA8S6UZwioVVfGfVaUSGM891y8jWmIlDvqF7WOWIBDWkd7HLvUX8GuJfRII2pN1Y0GQs0GGe2JpzIjeMvyMhuY4Uz1Z+tFyvxvV/5p7auHaLFkG0CJM0joCyDGp/mX8ZxVk0bkxdQaxhtoYpZ0piIrYFDrzQLYYzpHuxE4oJjmuwO4pMKLItkTf1iQ/tg4JA7QmXJDfHRgPkgivCuDyWJbyAGQDbclam6E7ipnRw/swQjf7G0WQaZ0cpqzXSgnZxOllxYfUQGxK+udVTolpb71dbM7f5l/uyBW//e1t9846qRGOnb8rqCw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t, #"Transaction Id" = _t, #"Item Code" = _t, #"Item Description" = _t, Qty = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type text}, {"Transaction Id", type text}, {"Item Code", type text}, {"Item Description", type text}, {"Qty", Int64.Type}}),
        #"Filtered Rows" = Table.SelectRows(#"Changed Type", each Text.StartsWith([Item Description], "Gif Voucher") or Text.StartsWith([Item Description], "Gift Voucher"))
    in
        #"Filtered Rows"
    • Prabunathan's avatar
      Prabunathan
      Frequent Visitor

      Hi Sir,

       

      Thank you for your guidance. May be i was not specific in my question on the earlier post.

       

      I need to actually filter the table by a search criteria by Items, and the rsulting table should be with transaction ID's which have the specific  "item"  + " Gift Vouchers " in them. 

       

      Just getting the total of Gift vouchers issued is not the requirement.

       

      Thanks in advance.

       

      Prabunathan

      • stretcharm's avatar
        stretcharm
        Memorable Member

        Apologies I didn't read the examples.

        Is the Item code a load filter or a Slicer on all the data?

         

         If a slicer then add a measure like this and Filter by the slicer for Item code and  in the filter pane HasGV>0

        HasGV = 
        VAR GV = "GV100"
        RETURN
            CALCULATE (
                COUNT ( Trans[Transaction Id] ),
                FILTER (
                    ALL ( Trans ),
                    Trans[Transaction Id] = MAX ( Trans[Transaction Id] )
                        && Trans[Item Code] = GV
                )
            )
  • Anonymous's avatar
    Anonymous
    Not applicable

    How can I set-up dynamic filtering when I have below scenario ?

    Say I have , Markets and I have Produt Units

    I want to selectively show the data for my employees with below type of access

    Type 1 - Belong to market ( easily done)

    Type 2 - Belong to Product Unit ( easily done)

    Type 4 - Global Access regardless of Market or Product Unit

    Type 3 - Belong to a specific Market and specific Product Unit

    For example - I have an employee who belongs to Market - America and part of Product Unit 1 and I want to display only the data for NAM --> Product Unit 1 can you help me on how the Type 3 can be implemented ?