Forum Discussion
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.
| Date | Transaction Id | Item Code | Item Description | Qty |
| 01-Dec-17 | A001 | PH001 | Asus Phone X001 | 3 |
| 01-Dec-17 | A001 | GV100 | Gif Voucher 100 | 3 |
| 04-Dec-17 | A002 | PH001 | Asus Phone X001 | 6 |
| 03-Dec-17 | A003 | PH001 | Asus Phone X001 | 4 |
| 03-Dec-17 | A003 | GV100 | Gif Voucher 100 | 4 |
| 04-Dec-17 | A004 | WM001 | Washing Machine B001 | 8 |
| 02-Dec-17 | A005 | WM001 | Washing Machine B001 | 9 |
| 02-Dec-17 | A005 | GV100 | Gif Voucher 100 | 9 |
| 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 ID | Qty | ||
| A001 | 3 | |||
| A003 | 4 | |||
| 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 ID | Qty | ||
| A005 | 9 |
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
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 ) )Yeah the calc doesn't work for the order number but the whole table.
I tried a different tactic using a summary table. Here is another doc
https://1drv.ms/u/s!Aln7Q7AFJHneiW2FVW26L2xmf6OQ
Maybe this page will help use as it seems to solve a similar problem.
http://www.daxpatterns.com/basket-analysis/
11 Replies
- stretcharmMemorable 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"- PrabunathanFrequent 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
- stretcharmMemorable 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 ) )
- AnonymousNot 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 ?