Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Segment

Hi all,

I have the following dataset: 

MonthIDProduct Amount
1A-001X5
1A-001Y4
1A-002X1
1A-003X10
2A-001X1
2A-001Y4
2A-002X6
2A-003X4

 

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!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

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.

 

Jihwan_Kim_0-1721670452444.png

 

Jihwan_Kim_1-1721670669463.png

 

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] )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Samarth_18
Community Champion
Community Champion

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:-

Samarth_18_0-1721671437978.png

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:-

Samarth_18_1-1721671664390.png

 

 

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

Jihwan_Kim
Super User
Super User

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.

 

Jihwan_Kim_0-1721670452444.png

 

Jihwan_Kim_1-1721670669463.png

 

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] )
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.