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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Calculate sum of column based on specific words in row

Hi all , I am new to power bi and I faced a challenge below.

I am required to calculate the output (4th column) based on start key word UDT-Wait(1st column) and end key word SBT(2nd column). The sum has to be reset and calculation needs to be repeated. 

Any idea how I can start?

KuannyGoh_0-1645438902543.png

 

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

 

Please first create index column in Power Query Editor.

vcgaomsft_1-1645680156819.pngIf the data is regular like in the graph, we can group by the regularity.

 

Group = INT(('Table'[Index]+2)/3)
sum = 
VAR _SUM =
    CALCULATE (
        SUM ( 'Table'[Column3] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Group] = EARLIER ( 'Table'[Group] ) )
    )
RETURN
    IF ( 'Table'[Column2] = "SBT", _SUM, BLANK () )

 

vcgaomsft_2-1645682343610.pngIf the data is irregular, we need to find another way. Please create a new column.

sum2 = 
VAR _step0 =
    IF ( 'Table'[Column2] = "SBT", 'Table'[Index], BLANK () )
VAR _step1 =
    CALCULATE (
        MAX ( 'Table'[Index] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Column1] = "UDT-Wait" ),
        FILTER ( ALL ( 'Table' ), 'Table'[Index] < _step0 )
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Column3] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Index] >= _step1 && 'Table'[Index] <= _step0 )
    )

vcgaomsft_0-1645694906273.png

Attach the pbix file for reference. Hope it helps.

 

Best Regards,
Community Support Team_Gao


If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors