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
newpbiuser01
Helper IV
Helper IV

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!

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

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.

vrzhoumsft_0-1686539515124.png

 

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.

 

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

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.

vrzhoumsft_0-1686539515124.png

 

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.

 

Thank you! that works beautifully!

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.