Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi all,
I have the following dataset:
| Month | ID | Product | Amount |
| 1 | A-001 | X | 5 |
| 1 | A-001 | Y | 4 |
| 1 | A-002 | X | 1 |
| 1 | A-003 | X | 10 |
| 2 | A-001 | X | 1 |
| 2 | A-001 | Y | 4 |
| 2 | A-002 | X | 6 |
| 2 | A-003 | X | 4 |
I would like to create customer segments based on amount, but as you see the segment changes every month. For example customer A-001 would be in month 1 in segment 5-10 but in month 2 in segment 1-5
I have tried to segment but it takes into account the total amount of all months (customer A-001, total amount 14, segment 10 - 15)
Could anyone help?
Thanks a lot!
Solved! Go to Solution.
Hi,
I am not sure how your semantic model looks like, but please try something like below.
Please check the below picture and the attached pbix file.
Sales: =
SUM( sales[Amount] )
Segment: =
VAR _sales = [Sales:]
VAR _segment =
FILTER ( Segment, Segment[min] <= _sales && Segment[max] >= _sales )
RETURN
IF (
HASONEVALUE ( 'ID'[ID] ) && HASONEVALUE ( 'Month'[Month] ),
MAXX ( _segment, Segment[Category] )
)
Hi @Anonymous ,
You can create a segment table(SegmentRanges) based on your range. so based on your sample, I have created a sample table as below:-
Now create a measure as below:-
Segment =
VAR CurrentMonth =
MAX ( SalesData[Month] )
VAR CurrentAmount =
CALCULATE (
SUM ( SalesData[Amount] ),
FILTER (
ALL ( Salesdata ),
Salesdata[Month] = CurrentMonth
&& Salesdata[ID] = MAX ( Salesdata[ID] )
)
)
RETURN
CALCULATE (
MAX ( SegmentRanges[Segment] ),
FILTER (
SegmentRanges,
CurrentAmount >= SegmentRanges[Lower Bound]
&& CurrentAmount <= SegmentRanges[Upper Bound]
),
Salesdata[Month] = CurrentMonth
)output:-
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
Hi,
I am not sure how your semantic model looks like, but please try something like below.
Please check the below picture and the attached pbix file.
Sales: =
SUM( sales[Amount] )
Segment: =
VAR _sales = [Sales:]
VAR _segment =
FILTER ( Segment, Segment[min] <= _sales && Segment[max] >= _sales )
RETURN
IF (
HASONEVALUE ( 'ID'[ID] ) && HASONEVALUE ( 'Month'[Month] ),
MAXX ( _segment, Segment[Category] )
)
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 40 | |
| 35 | |
| 34 | |
| 31 | |
| 28 |
| User | Count |
|---|---|
| 137 | |
| 102 | |
| 68 | |
| 66 | |
| 64 |