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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
fab196
Helper II
Helper II

Sum OF values

Hi Everyone ,

 

need your help

i want use power query and generate the result below

 

I have with two columns first is original col and second one is derived column as mentioned the below

i want to amke a running toatl but in different way

in the example listed below if the values are not macthing from both columns a and b then the deafualt value is will 1 in the result col

if the values are macthing then it should be add 1 to each values

AB  result 
1NULL initial  value is nulll then it should be 1(in short values are not matching)1
11 it is matching so added above value 1+ 12
21 both values are not macthing so 1
22 macthing then adding above 1+12
22 macthing so above 2+13
32 not macthing so 11
43 not macthing so 11
44 macthing so above 1 value and add 1 into that so 1+12

 @amitchandak 

@parry2k 

@v-luwang-msft 

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@fab196 , a new column

 

new column =

vat _b = [B]+0

return

countx(filter(Table, [A] = earlier([A]) && [B]+0 <= +b ), [A])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

v-yanjiang-msft
Community Support
Community Support

Hi @fab196 ,

According to your description, it's more easier to achieve it by DAX, here's my solution.

1.In Power Query, add an index column.

vkalyjmsft_0-1644912351517.png

Get this table.

vkalyjmsft_1-1644912391080.png

2.Create a calculated column.

Count =
VAR _RANK =
    RANKX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[ColumnA] = EARLIER ( 'Table'[ColumnA] )
                && 'Table'[ColumnB] = EARLIER ( 'Table'[ColumnB] )
                && 'Table'[ColumnA] = 'Table'[ColumnB]
        ),
        'Table'[Index],
        ,
        ASC,
        DENSE
    )
RETURN
    IF ( 'Table'[ColumnA] = 'Table'[ColumnB], _RANK + 1, _RANK )

Get the expected result.

vkalyjmsft_2-1644912623613.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

5 REPLIES 5
v-yanjiang-msft
Community Support
Community Support

Hi @fab196 ,

According to your description, it's more easier to achieve it by DAX, here's my solution.

1.In Power Query, add an index column.

vkalyjmsft_0-1644912351517.png

Get this table.

vkalyjmsft_1-1644912391080.png

2.Create a calculated column.

Count =
VAR _RANK =
    RANKX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[ColumnA] = EARLIER ( 'Table'[ColumnA] )
                && 'Table'[ColumnB] = EARLIER ( 'Table'[ColumnB] )
                && 'Table'[ColumnA] = 'Table'[ColumnB]
        ),
        'Table'[Index],
        ,
        ASC,
        DENSE
    )
RETURN
    IF ( 'Table'[ColumnA] = 'Table'[ColumnB], _RANK + 1, _RANK )

Get the expected result.

vkalyjmsft_2-1644912623613.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

amitchandak
Super User
Super User

@fab196 , a new column

 

new column =

vat _b = [B]+0

return

countx(filter(Table, [A] = earlier([A]) && [B]+0 <= +b ), [A])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

can we do it using power query?

 

@fab196 , refer if this can help

https://www.youtube.com/watch?v=7CqXdSEN2k4

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

col a PREVIOUS ROW  
ANULLHERE IS NULL SO DEFAULT VALUE IS 11
AAA=A SO ADDITION LIKE ABOVE 1 VALUE PLUS ADD 12
AAA=A SO ADDITION LIKE ABOVE 1 VALUE PLUS ADD 23
BAB<>A SO 1
CBC<>B1

 

I WANT TO RESULT LIKE THIS

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

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.