Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I was wondering if it is possible to do this kind of grouping for two columns based on the sign of the interval values (and how).
The months are selected by a slicer in the report.
Thanks for the help
Solved! Go to Solution.
Hi @Anonymous
Please refer to the attached sample file with the solution.
Rank =
VAR Ranking1 =
RANKX ( FILTER ( 'Table', 'Table'[Value] > 0 ), 'Table'[Month],, ASC, Dense )
VAR Ranking2 =
RANKX ( FILTER ( 'Table', 'Table'[Value] < 0 ), 'Table'[Month],, ASC, Dense )
VAR Result =
IF ( 'Table'[Value] > 0, Ranking2, Ranking1 )
RETURN
Result
Group =
VAR CurrentGroupTable =
CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Rank] ) )
VAR Starting =
MINX ( CurrentGroupTable, 'Table'[Month] )
VAR Ending =
MAXX ( CurrentGroupTable, 'Table'[Month] )
RETURN
FORMAT ( Starting, "MMMM" ) & " - " & FORMAT ( Ending, "MMMM" )
Average Value = AVERAGE ( 'Table'[Value] )
Hello @tamerj1 & @Jihwan_Kim , thank you for your nice answsers.
@tamerj1's solution is the closest to what I need. I'll just add a new measure so that the period label reflects more precisely the selected period and hid the month group.
Thank you again for the help and the effort, much appreciated
Hi @Anonymous
Please refer to the attached sample file with the solution.
Rank =
VAR Ranking1 =
RANKX ( FILTER ( 'Table', 'Table'[Value] > 0 ), 'Table'[Month],, ASC, Dense )
VAR Ranking2 =
RANKX ( FILTER ( 'Table', 'Table'[Value] < 0 ), 'Table'[Month],, ASC, Dense )
VAR Result =
IF ( 'Table'[Value] > 0, Ranking2, Ranking1 )
RETURN
Result
Group =
VAR CurrentGroupTable =
CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Rank] ) )
VAR Starting =
MINX ( CurrentGroupTable, 'Table'[Month] )
VAR Ending =
MAXX ( CurrentGroupTable, 'Table'[Month] )
RETURN
FORMAT ( Starting, "MMMM" ) & " - " & FORMAT ( Ending, "MMMM" )
Average Value = AVERAGE ( 'Table'[Value] )
Hi,
Please check the below picture and the attached pbix file.
It is for creating a new table.
New Table =
VAR _previousvalue =
ADDCOLUMNS (
Data,
"@prev",
CALCULATE (
SUM ( Data[Value] ),
FILTER ( Data, Data[Month number] = EARLIER ( Data[Month number] ) - 1 )
)
)
VAR _condition =
ADDCOLUMNS (
_previousvalue,
"@condition",
IF ( Data[Value] * [@prev] >= 0, 0, 1 )
)
VAR _group =
ADDCOLUMNS (
_condition,
"@group",
SUMX (
FILTER ( _condition, Data[Month number] <= EARLIER ( Data[Month number] ) ),
[@condition]
)
)
VAR _newtable =
ADDCOLUMNS (
_group,
"@month",
MAXX (
FILTER (
Data,
Data[Month number]
= MINX ( FILTER ( _group, [@group] = EARLIER ( [@group] ) ), Data[Month number] )
),
Data[Month]
) & "~"
& MAXX (
FILTER (
Data,
Data[Month number]
= MAXX ( FILTER ( _group, [@group] = EARLIER ( [@group] ) ), Data[Month number] )
),
Data[Month]
)
)
VAR _avgcolumn =
ADDCOLUMNS (
_newtable,
"@avgvalue", AVERAGEX ( FILTER ( _group, [@group] = EARLIER ( [@group] ) ), Data[Value] )
)
RETURN
SUMMARIZE ( _avgcolumn, [@month], [@avgvalue] )
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
9 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
11 | |
11 | |
10 | |
6 |