March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi all,
I am trying to compare this months billing values with last months billing values. So the question i am trying to answer is "How many new customers do we have this month compared to last?". What is the best approach here to make it as dynamic as possible, i.e. to make it rolling month on month?
I am comparing the Billing Month field and has 2 months worth of data, i.e. Feb and March. Ideally what I want my answer to display is the 2 new customers, as like below and highlighted above. These are the 2 new customers.
Once I have this I would also like to see which customers we have lost between March and Feb i.e. as they existed in Feb but not in March.
Solved! Go to Solution.
Hi @darraghfarrell ,
Open Query Editor, apply below changes to source table.
let Source = Excel.Workbook(File.Contents("C:\Users\xxxx\Desktop\Sample Data 2.xlsx"), null, true), Sample_2_Sheet = Source{[Item="Sample_2",Kind="Sheet"]}[Data], #"Promoted Headers" = Table.PromoteHeaders(Sample_2_Sheet, [PromoteAllScalars=true]), #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Billing Month", type date}, {"Customer name", type text}}), #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Billing Month", Order.Ascending}}), #"Grouped Rows" = Table.Group(#"Sorted Rows", {"Billing Month"}, {{"all data", each _, type table [Billing Month=date, Customer name=text]}}), #"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Index", 1, 1), #"Expanded all data" = Table.ExpandTableColumn(#"Added Index", "all data", {"Customer name"}, {"all data.Customer name"}), #"Renamed Columns" = Table.RenameColumns(#"Expanded all data",{{"all data.Customer name", "Customer name"}}) in #"Renamed Columns"
In Data view mode, create a calculated column.
Lost/New this month = VAR isFindnextMonth = IF ( LOOKUPVALUE ( Sample_2[Customer name], Sample_2[Customer name], Sample_2[Customer name], Sample_2[Index], Sample_2[Index] + 1 ) = BLANK (), 0, 1 ) VAR isFindpreMonth = IF ( LOOKUPVALUE ( Sample_2[Customer name], Sample_2[Customer name], Sample_2[Customer name], Sample_2[Index], Sample_2[Index] - 1 ) = BLANK (), 0, 1 ) RETURN IF ( Sample_2[Billing Month] <> MIN ( Sample_2[Billing Month] ) && isFindpreMonth = 0, "New", IF ( Sample_2[Billing Month] <> MAX ( Sample_2[Billing Month] ) && isFindnextMonth = 0, "Lost", "" ) )
Best regards,
Yuliana Gu
Hi @darraghfarrell ,
Open Query Editor, apply below changes to source table.
let Source = Excel.Workbook(File.Contents("C:\Users\xxxx\Desktop\Sample Data 2.xlsx"), null, true), Sample_2_Sheet = Source{[Item="Sample_2",Kind="Sheet"]}[Data], #"Promoted Headers" = Table.PromoteHeaders(Sample_2_Sheet, [PromoteAllScalars=true]), #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Billing Month", type date}, {"Customer name", type text}}), #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Billing Month", Order.Ascending}}), #"Grouped Rows" = Table.Group(#"Sorted Rows", {"Billing Month"}, {{"all data", each _, type table [Billing Month=date, Customer name=text]}}), #"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Index", 1, 1), #"Expanded all data" = Table.ExpandTableColumn(#"Added Index", "all data", {"Customer name"}, {"all data.Customer name"}), #"Renamed Columns" = Table.RenameColumns(#"Expanded all data",{{"all data.Customer name", "Customer name"}}) in #"Renamed Columns"
In Data view mode, create a calculated column.
Lost/New this month = VAR isFindnextMonth = IF ( LOOKUPVALUE ( Sample_2[Customer name], Sample_2[Customer name], Sample_2[Customer name], Sample_2[Index], Sample_2[Index] + 1 ) = BLANK (), 0, 1 ) VAR isFindpreMonth = IF ( LOOKUPVALUE ( Sample_2[Customer name], Sample_2[Customer name], Sample_2[Customer name], Sample_2[Index], Sample_2[Index] - 1 ) = BLANK (), 0, 1 ) RETURN IF ( Sample_2[Billing Month] <> MIN ( Sample_2[Billing Month] ) && isFindpreMonth = 0, "New", IF ( Sample_2[Billing Month] <> MAX ( Sample_2[Billing Month] ) && isFindnextMonth = 0, "Lost", "" ) )
Best regards,
Yuliana Gu
Hi,
Share the link from where i can download your PBI file.
@darraghfarrell check this blog, hope it helps
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
114 | |
76 | |
57 | |
52 | |
44 |
User | Count |
---|---|
164 | |
116 | |
63 | |
57 | |
50 |