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.
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] )
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 | |
8 |
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
8 |