Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Filter out clients that have a value

Hi All,

I am currently trying to create a report where it shows the clients that have not had returns.
I would preferable like to do it through a DAX measure so that I can use date filters and other filters at a later stage.
I have three tables I am working with, I have simplified them as much as possible just to reflect the data model I am working with.
The tables are as follows:


Customers

Customer_IDCustomer_Name
1John
2Bob

 

Fact_Tansactions

Transaction_NoAmountCustomer_ID
11001
21001
32002
4502
52002

 

Transaction_desc

Transaction_NoTransaction_TypeTransaction_Date
1Purchase10/10/2021
2Purchase12/10/2021
3Purchase18/10/2021
4Purchase20/10/2021
5Return28/10/2021

 

The Customer and Transaction_desc tables are moth linked to the Fact_Transaction table.

The output I would like to create is:

Customer_NameAmount
John200

 

Where the measure excludes all of the transactions when calculating the amount for Customer_ID 2 because of the turn they have on the Transcation_desc table.

Any help will be much appreciated, thank you.

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    According to this——shows the clients that have not had returns

    You could firstly create a flag measure:

    Flag =
    VAR _AllTranType =
        ADDCOLUMNS (
            SUMMARIZE ( 'Fact_Tansactions', [Customer_ID], [Transaction_No] ),
            "Type",
                LOOKUPVALUE (
                    'Transaction_desc'[Transaction_Type],
                    [Transaction_No], 'Fact_Tansactions'[Transaction_No]
                )
        )
    VAR _t =
        SUMMARIZE (
            FILTER ( _AllTranType, [Customer_ID] = MAX ( 'Customers'[Customer_ID] ) ),
            [Type]
        )
    RETURN
        IF ( "Return" IN _t, 1, 0 )
    

    And apply it to visual-level filter , set as "is 1":

    Or if you want to show all customers on a Card visual, please try:

    All Customers did not return = CONCATENATEX(FILTER('Customers',[Flag]=1),[Customer_Name],",")

    Final Output:

     

     Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

  • Anonymous , Not very clear, is customer 2 not appearing because of return.

    Seems like simple addition unless we use logic of the return

     

    if it is 1-1 or then we can get their type

    in Fact_Tansactions

    maxx(filter(Transaction_desc, Transaction_desc[Transaction_No] = Fact_Tansactions[Transaction_No] ) ,Transaction_desc[Transaction_Type] )

     

    if they are 1=1, then better to merge those

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi amitchandak ,

      Thank you for your help, and sorry if I wasn't completely clear.


      To answer your first question: yes I don't want customer 2 showing on the table due to there being a refund for them.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    According to this——shows the clients that have not had returns

    You could firstly create a flag measure:

    Flag =
    VAR _AllTranType =
        ADDCOLUMNS (
            SUMMARIZE ( 'Fact_Tansactions', [Customer_ID], [Transaction_No] ),
            "Type",
                LOOKUPVALUE (
                    'Transaction_desc'[Transaction_Type],
                    [Transaction_No], 'Fact_Tansactions'[Transaction_No]
                )
        )
    VAR _t =
        SUMMARIZE (
            FILTER ( _AllTranType, [Customer_ID] = MAX ( 'Customers'[Customer_ID] ) ),
            [Type]
        )
    RETURN
        IF ( "Return" IN _t, 1, 0 )
    

    And apply it to visual-level filter , set as "is 1":

    Or if you want to show all customers on a Card visual, please try:

    All Customers did not return = CONCATENATEX(FILTER('Customers',[Flag]=1),[Customer_Name],",")

    Final Output:

     

     Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.