This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi,
How do I write DAX to calculate these?
I'd like to achieve the Total column number.
Thank you,
Solved! Go to Solution.
Hi,
PBI file attached.
Hope this helps.
hello @topazz11
please check if this accomodate your need.
1. Unpivot your table and change null value into 0
2. create a calculated column to seek min value of consecutive date
Min Date =
var _Date =
ADDCOLUMNS(
ADDCOLUMNS(
'Table',
"Next Date",
MAXX(
FILTER(
'Table',
'Table'[Item]=EARLIER('Table'[Item])&&
'Table'[Date]<EARLIER('Table'[Date])
),
'Table'[Date]
)
),
"ConsDate",
MAXX(
FILTER(
'Table',
'Table'[Item]=EARLIER('Table'[Item])&&
'Table'[Date]=[Next Date]
),
'Table'[Value]
)
)
Return
MAXX(
FILTER(
_Date,
'Table'[Item]=EARLIER('Table'[Item])&&
'Table'[Value]=1&&
[ConsDate]=0
),
'Table'[Date]
)
Max Date =
var _Date =
ADDCOLUMNS(
ADDCOLUMNS(
ADDCOLUMNS(
ADDCOLUMNS(
'Table',
"Next Date",
MAXX(
FILTER(
'Table',
'Table'[Item]=EARLIER('Table'[Item])&&
'Table'[Date]<EARLIER('Table'[Date])
),
'Table'[Date]
)
),
"ConsDate",
MAXX(
FILTER(
'Table',
'Table'[Item]=EARLIER('Table'[Item])&&
'Table'[Date]=[Next Date]
),
'Table'[Value]
)
),
"IFMax",
var _Max =
MAXX(
FILTER(
'Table',
'Table'[Item]=EARLIER('Table'[Item])&&
'Table'[Value]=1&&
[ConsDate]=1
),
'Table'[Date]
)
Return
IF(
'Table'[Min Date]='Table'[Date],
'Table'[Date],
_Max
)),
"MaxDate",
MAXX(
FILTER(
'Table',
'Table'[Item]=EARLIER('Table'[Item])
),
[IFMax]
)
)
Return
MAXX(
FILTER(
_Date,
'Table'[Item]=EARLIER('Table'[Item])
),
[MaxDate]
)
Datediff =
DATEDIFF(
'Table'[Min Date],
'Table'[Max Date],
DAY
)+1
@topazz11 I found a number of references to "Cthulhu" or "Streaks" by Greg Deckler. From what I see the technique should allow you to achieve your desired result. I have not personally tested the DAX code however.
How to find and report on streaks in data | Greg Deckler posted on the topic | LinkedIn
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 31 | |
| 26 | |
| 23 | |
| 22 | |
| 13 |
| User | Count |
|---|---|
| 62 | |
| 47 | |
| 28 | |
| 23 | |
| 19 |