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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
htittoto
Frequent Visitor

CountIfs by past data

559B572A-E902-49E4-8180-76467D4D1A94.jpeg

Hello,

 

could someone help me? I'm trying to built a column in power query to count how many times have I made a sale and, most importantly, what sale (order by brand and date) was that. The image shows that the column "Previous Sale Count by Make" is what I'm having trouble with.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

you mjust load you data and goes unde view/advance editors panel in PBI (I understood you use PBI, is it true?).

image.png

 

 

inside this panel cut and paste the lines of code you find in my post.

edit and modify so that you have a situation like this:

 

 

image.png

 

 

that is all.

 

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

a guess for the "hard" part only 😁

you have to add these lines after your lasta step and adapt the name of yourTab and other parameter as you like:

 

    grp = Table.Group(yourTab, {"Make"}, {{"grpMake", each Table.AddIndexColumn(_, "Prev by Make", 0, 1)}}),
    resulTab= Table.Sort(Table.ExpandTableColumn(grp, "grpMake", {"Model", "date", "Prev by Make"}),"date")
in
    resulTab

 

 

Thanks for replying @Anonymous ,

 

unfortunately, I couldn't quite understand how to implement it, I believe I'm not that advanced in PBI yet. Could you please explain step-by-step how to implement it a little bit more, please?

Anonymous
Not applicable

you mjust load you data and goes unde view/advance editors panel in PBI (I understood you use PBI, is it true?).

image.png

 

 

inside this panel cut and paste the lines of code you find in my post.

edit and modify so that you have a situation like this:

 

 

image.png

 

 

that is all.

 

 

Thanks @Anonymous ! 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors