Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
Solved! Go to Solution.
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/
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 ?
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"
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
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 ) )
Hi
Thank you and it works fantastic.
Great.
No problem.
Hi Sir,
Apologies to trouble you again. Although i tried your solution on a sample work, I failed to apply your advice and lost in the DAX. I am not familiar with VAR, FILTERS in DAX.
It is difficult for me narrate my requirement, Hence i am sharing a sample Pbix which may help you to understand my requirement and correct my DAX measure syntax.
https://www.dropbox.com/s/ablz8s4681ospwt/Sample.pbix?dl=0
Appreciate your support.
Regards
Prabu
Looks like a typo on the voucher number. It's ZO not Z0
HasGV1 = VAR GV = "ZOTGVCB100ISM" RETURN CALCULATE ( COUNT ( MASTER[Order No. ] ), FILTER ( ALL ( MASTER ), MASTER[Order No. ] = MAX( MASTER[Order No. ] ) && MASTER[Item] = GV ) )
Variables are easy and make the code a little easier to read an change especially if you use values multiple times.
https://www.sqlbi.com/blog/marco/2017/09/12/the-easiest-way-to-start-using-variables-in-dax/
https://docs.microsoft.com/en-us/power-bi/guided-learning/introductiontodax#step-4
https://powerbi.tips/2017/05/using-variables-within-dax/
Hi Sir,
Thank you again. I request you to return me the Pbix file with the filter in action.
I tried after correcting the code, but the matrix table stil showsup ALL Order Id's which contain ZOTGVCB100ISM, whereas i need the resulting matrix table to showup only the filtered OrderID's which contain BOTH Item "Samsung SP N950" + "ZOTGVCB100ISM".
Regards
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/
Hi Sir,
Thank you . This one worked perfect and thanks once again for all the links provided.
Regards
Prabu
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
97 | |
94 | |
74 | |
71 | |
64 |
User | Count |
---|---|
143 | |
109 | |
103 | |
82 | |
74 |