Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Prabunathan
Frequent Visitor

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

2 ACCEPTED SOLUTIONS

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
        )
    )

View solution in original post

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/

 

View solution in original post

11 REPLIES 11
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 ?

stretcharm
Memorable Member
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"

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.