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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mushir1232
Regular Visitor

CountIf with Sequence Result

Hi All,

Need Assistance in Power Query  to DAX Measure to get the Sequential Count result on Countif.

I have applied : =COUNTIF($A$2:A2,A2)

 

mushir1232_0-1683873282658.png

 

2 REPLIES 2
AlienSx
Super User
Super User

Hi, @mushir1232 you'd probably want to keep sorting order so I added index column before transformation and removed it in the end. 

let
    // Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Source = <your_table>,
    sort_col = Table.AddIndexColumn(Source, "sort", 0, 1, Int64.Type),
    f = (tbl as table) as table => [a = Table.Sort(tbl, "sort"), b = Table.AddIndexColumn(a, "Result", 1, 1, Int64.Type)][b],
    g = Table.Group(sort_col, "Data", {{"all", each f(_)}}),
    all = Table.Combine(g[all]),
    sort_again = Table.Sort(all,{{"sort", Order.Ascending}}),
    remove_sort = Table.RemoveColumns(sort_again,{"sort"})
in
    remove_sort

Hi, thanks for your time to workout.

What I Need a another Column in front of my Data showing the No of Counts . I want to know how many times the item is there in the Column with a sequence.

If A is available in Different Row , in the given sample 4 times, so from the Top the It is counting and checking and providing the No of Counts from the Top always.

Similar to COUNTIF($A$2:A2,A2) in Excel

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.