Forum Discussion

newpbiuser01's avatar
newpbiuser01
Icon for Helper V rankHelper V
3 years ago
Solved

Flagging Change in Data from Previous Month

Hello,

I have a table that lists the method of payment by a vendor and the month/year the transaction took place. 

VendorMonth-YearMethod
A2-2021Debit Card
A2-2021Credit Card
B3-2021Debit Card
C5-2021Credit Card
D1-2022Credit Card
E2-2022Check
B9-2023Check
C7-2021Credit Card
D11-2022Debit Card
A8-2023Check
B12-2022Credit Card
C7-2023Debit Card
D8-2021Check
B1-2023Debit Card

 

I need to create a report that flags the method change each month by vendor. So for vendor A, first get the different methods used in the same month - so in February 2021 (2-2021), vendor A paid us through debit card and then by credit card once. So for that month, the method would be concatenated to be Credit Card, Debit Card.  

The next step would be to get the method for the previous month (1-2021), and get the method and then flag it they were the same or not. So the result would be:

 

VendorMonth-YearPrevious Month-YearCurrent MethodPrevious MethodFlag
A2-20211-2021Debit Card, Credit Card -
B3-20212-2021Debit CardDebit Card, Credit CardChange
C5-20214-2021Credit Card -
D1-202212-2021Credit Card -
E2-20221-2022CheckCredit CardChange
B9-20238-2023CheckCheckSame
C7-20216-2021Credit Card -
D11-202210-2022Debit Card -
A8-20237-2023CheckDebit CardChange
B12-202211-2022Credit CardDebit CardChange
C7-20236-2023Debit 
D8-20217-2021CheckCredit CardChange
B1-202312-2022Debit CardCredit CardChange

 

I think it has to be done in calculated columns because I need to calculate it for each row and flag each vendor record for each month/year. But, given that we have a large data set, I can't figure out how to do this. Would anyone know how I could do this?

 

Really appreciate any help!

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi newpbiuser01 ,

     

    I suggest you to convert [Month-Year] column as Date data type column and format it in MM-YYYY. This will make your calculation easier.

    Measures:

    Previous Month-Year = 
    EOMONTH(MAX('Table'[Month-Year]),-2)+1
    Current Method = 
    CONCATENATEX('Table',[Method],", ")
    Previous Method = 
    CALCULATE (
        [Current Method],
        FILTER (
            ALL ( 'Table' ),
            'Table'[Month-Year]
                = EOMONTH ( MAX ( 'Table'[Month-Year] ), -2 ) + 1
        )
    )
    Flag = 
    IF (
        [Previous Method] = BLANK (),
        "-",
        IF ( [Current Method] = [Previous Method], "Same", "Change" )
    )

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

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

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi newpbiuser01 ,

     

    I suggest you to convert [Month-Year] column as Date data type column and format it in MM-YYYY. This will make your calculation easier.

    Measures:

    Previous Month-Year = 
    EOMONTH(MAX('Table'[Month-Year]),-2)+1
    Current Method = 
    CONCATENATEX('Table',[Method],", ")
    Previous Method = 
    CALCULATE (
        [Current Method],
        FILTER (
            ALL ( 'Table' ),
            'Table'[Month-Year]
                = EOMONTH ( MAX ( 'Table'[Month-Year] ), -2 ) + 1
        )
    )
    Flag = 
    IF (
        [Previous Method] = BLANK (),
        "-",
        IF ( [Current Method] = [Previous Method], "Same", "Change" )
    )

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

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