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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors