Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have a scenario where I need to get summary of values till it encounters zero and reset the summary to zero once it has the zero value.
Solved! Go to Solution.
Hi @Anonymous ,
Here are the steps you can follow:
1.Create calculated column.
Column1 =
IF(
'Table'[YELLOW]=0,1,0)
Column2 =
SUMX(
FILTER(ALL('Table'),
'Table'[FW_ID]<=EARLIER('Table'[FW_ID])),[Column1])
2. Create measure.
Test1 =
IF(
MAX('Table'[Column1])=1,BLANK(),
COUNTX(
FILTER(ALLSELECTED('Table'),
'Table'[Column2]=MAX('Table'[Column2])&&[Column1]<>1),[FW_ID]))
Test2 =
SUMX(
FILTER(ALL('Table'),[Test1]>1),[YELLOW])
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi,
I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.
It is for cumulative sum grouped by non-consecutive-zero.
expected result measure: =
VAR _yellow =
ADDCOLUMNS ( ALL ( data ), "@yellow", [yellow:] )
VAR _condition =
ADDCOLUMNS ( _yellow, "@condition", IF ( [@yellow] = 0, 1, 0 ) )
VAR _group =
ADDCOLUMNS (
_condition,
"@group",
SUMX (
FILTER ( _condition, data[fw_id] <= EARLIER ( data[fw_id] ) ),
[@condition]
)
)
VAR _currentrowgroup =
MAXX ( FILTER ( _group, data[fw_id] = MAX ( data[fw_id] ) ), [@group] )
RETURN
SUMX (
FILTER (
_group,
[@group] = _currentrowgroup
&& data[fw_id] <= MAX ( data[fw_id] )
),
[@yellow]
)
Hi,
I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.
It is for cumulative sum grouped by non-consecutive-zero.
expected result measure: =
VAR _yellow =
ADDCOLUMNS ( ALL ( data ), "@yellow", [yellow:] )
VAR _condition =
ADDCOLUMNS ( _yellow, "@condition", IF ( [@yellow] = 0, 1, 0 ) )
VAR _group =
ADDCOLUMNS (
_condition,
"@group",
SUMX (
FILTER ( _condition, data[fw_id] <= EARLIER ( data[fw_id] ) ),
[@condition]
)
)
VAR _currentrowgroup =
MAXX ( FILTER ( _group, data[fw_id] = MAX ( data[fw_id] ) ), [@group] )
RETURN
SUMX (
FILTER (
_group,
[@group] = _currentrowgroup
&& data[fw_id] <= MAX ( data[fw_id] )
),
[@yellow]
)
Hi @Anonymous ,
Here are the steps you can follow:
1.Create calculated column.
Column1 =
IF(
'Table'[YELLOW]=0,1,0)
Column2 =
SUMX(
FILTER(ALL('Table'),
'Table'[FW_ID]<=EARLIER('Table'[FW_ID])),[Column1])
2. Create measure.
Test1 =
IF(
MAX('Table'[Column1])=1,BLANK(),
COUNTX(
FILTER(ALLSELECTED('Table'),
'Table'[Column2]=MAX('Table'[Column2])&&[Column1]<>1),[FW_ID]))
Test2 =
SUMX(
FILTER(ALL('Table'),[Test1]>1),[YELLOW])
3. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
13 | |
12 | |
11 | |
11 | |
8 |