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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Count values in row in DAX

Hello,

I have weekly collected project trends data (please check in attachment) I would like to build DAX column which counts  no of weeks in last state, ideally it should start counting if state is changing. So e.g project was in Amber state for 10 weeks but it changed to green and it should start counting one more time.

 

25-02-19 10-48-59.png

 

Could you advise, please?

Thanks!

4 REPLIES 4
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous ,

 

Does above image show the source data table? Do you want to count the number of weeks per row? How to count? Could you please show us the desired result with examples?

 

Best regards,

Yuliana Gu

 

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-yulgu-msft,

Above are shown some dummy data I created to show how data are collected and what I want to build.
I would like to build an expression which will count for each row no of cells in a row with followinh logic:

rw - row

cl - column

n - variable
if cell(rw, cl) = cell(rw, cl+1) then n = n+1

else if cell(rw,cl) <> cell(rw, cl +1) then n = 1


Main point of it it to count no of weeks in current state, not all specific values but to start counting again if cells have different value.




Anonymous
Not applicable

hello @Anonymous,

try using VBA to solve that issue

Anonymous
Not applicable

Already did it in VBA - but thank you 🙂

I just wonder if this is possible in DAX too

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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.