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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
phgatto
New Member

Compare a client performance versus a segment performance

Hello Everyone,
I would like to find the best way to compare a client performance versus a particular segment it is part of. 
For example: When consulting a company performance in the Oil and Gas segment,
it should bring the result of that specific company comparing with the other companies in that segment.

 

1 ACCEPTED SOLUTION

Hi @phgatto 

Thanks for reaching out to us.

 

You can try this,

 

Measure1 = 
    var _minYear=CALCULATE(MIN('Table'[YEAR]),ALLSELECTED('Table'))
    var _maxYear=CALCULATE(MAX('Table'[YEAR]),ALLSELECTED('Table'))
    var _value1=CALCULATE(MAX('Table'[REVENUE]),FILTER(ALLSELECTED('Table'),'Table'[YEAR]=_minYear))
    var _value2=CALCULATE(MAX('Table'[REVENUE]),FILTER(ALLSELECTED('Table'),'Table'[YEAR]=_maxYear))
return (_value2-_value1)/_value1
Measure2 = 
    var _getSegment=SELECTEDVALUE('Table'[SEGMENT])
    var _getClient=SELECTEDVALUE('Table'[CLIENT])
    var _minYear=CALCULATE(MIN('Table'[YEAR]),ALLSELECTED('Table'))
    var _maxYear=CALCULATE(MAX('Table'[YEAR]),ALLSELECTED('Table'))
    var _value1=CALCULATE(SUM('Table'[REVENUE]),FILTER(ALL('Table'),'Table'[YEAR]=_minYear && 'Table'[CLIENT]<>_getClient && 'Table'[SEGMENT] =_getSegment))
    var _value2=CALCULATE(SUM('Table'[REVENUE]),FILTER(ALL('Table'),'Table'[YEAR]=_maxYear && 'Table'[CLIENT]<>_getClient && 'Table'[SEGMENT] =_getSegment))
return (_value2-_value1)/_value1

 

vxiaotang_0-1635497046622.png

vxiaotang_1-1635497072353.png

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
phgatto
New Member

First of all, sorry for replying too long later. 
I admit that I still had difficulties in solving the problem.
As the information is divided into different tables, I will share the way the data is structured and so, it may be simpler.

 

First sheet:

MonthHotelClient CodeRevenue
jan/19Hotel XYZ4353249
jan/19Hotel XYZ38512825982
jan/19Hotel XYZ15941769355
feb/19Hotel XYZ435759
feb/19Hotel XYZ38512842165
feb/19Hotel XYZ1594176935
mar/19Hotel XYZ4350
mar/19Hotel XYZ38512828037
mar/19Hotel XYZ1594176955
apr/19Hotel XYZ4351001
apr/19Hotel XYZ38512832867
apr/19Hotel XYZ1594176355
may/19Hotel XYZ4352521
may/19Hotel XYZ38512870034
may/19Hotel XYZ159417610355
jan/21Hotel XYZ4350
jan/21Hotel XYZ38512856707
jan/21 Hotel XYZ159417629355
feb/21Hotel XYZ435 886
feb/21Hotel XYZ38512849385
feb/21Hotel XYZ1594176896
mar/21Hotel XYZ4355684
mar/21Hotel XYZ3851284364
mar/21 Hotel XYZ159417627244
apr/21Hotel XYZ43512972
apr/21Hotel XYZ3851287633
apr/21Hotel XYZ1594176244
may/21Hotel XYZ4357244
may/21Hotel XYZ3851289323
may/21Hotel XYZ1594176724

 

Second Sheet:

Client CodeClient NameClient GroupSegmentCountry
1594176John TourJohn TourTour OperatorBrazil
1595257John TourJohn TourTour OperatorUSA
274988John TourJohn TourTour OperatorSpain
435Mary TourMary TourTour OperatorUK
385128Terry TourTerry TourTour OperatorBrazil

 

The idea is compare a single client, or the group he belongs to, versus the segment he belongs to, for example: 
Filtering by the single client John Tour (Brazil), it compares the performance of that client over the months
against all others in the segment.
If I filter the John Tour Group (Brazil, USA and Spain) it compares the performance of this group versus
the other clients not selected from the tour operator segment.
The idea is to insert a bar graph like the one below.

phgatto_0-1636469434597.png

I hope I've been more efficient in my explanation now. Thanks again.

Greg_Deckler
Super User
Super User

@phgatto Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

YEARCLIENTSEGMENTREVENUE
2020Client 1Travel Agency1000
2020Client 2Travel Agency1000
2020Client 3Travel Agency500
2020Client 4Tour Operator1500
2020Client 5Tour Operator2000
2020Client 6Tour Operator300
2021Client 1Travel Agency1500
2021Client 2Travel Agency2000
2021Client 3Travel Agency800
2021Client 4Tour Operator500
2021Client 5Tour Operator700
2021Client 6Tour Operator400

In this case the total revenue per segment is:

2020 TRAVEL AGENCY - 2,500

2020 TOUR OPERATOR - 3,800

 

2021 TRAVEL AGENCY - 4,300

2021 TOUR OPERATOR - 1,600

 

For example: I choose the Client 1 (segment Travel Agency), the variation YoY is: +50% (1,000 vs. 1,500)

The Segment Travel Agency (excluding Client 1) variated: +87% (1,500 vs 2,800).

 

If I choose Client 5 (segment Tour Operator), the variation is: -65% (700 vs 2,000)

The Segment Tour Operator (excluding Client 5) variated: -50% (1,800 vs 900).

 

I would like to use Bar charts to compare the variation of a specific client versus the segment its is part of.

Hi @phgatto 

Thanks for reaching out to us.

 

You can try this,

 

Measure1 = 
    var _minYear=CALCULATE(MIN('Table'[YEAR]),ALLSELECTED('Table'))
    var _maxYear=CALCULATE(MAX('Table'[YEAR]),ALLSELECTED('Table'))
    var _value1=CALCULATE(MAX('Table'[REVENUE]),FILTER(ALLSELECTED('Table'),'Table'[YEAR]=_minYear))
    var _value2=CALCULATE(MAX('Table'[REVENUE]),FILTER(ALLSELECTED('Table'),'Table'[YEAR]=_maxYear))
return (_value2-_value1)/_value1
Measure2 = 
    var _getSegment=SELECTEDVALUE('Table'[SEGMENT])
    var _getClient=SELECTEDVALUE('Table'[CLIENT])
    var _minYear=CALCULATE(MIN('Table'[YEAR]),ALLSELECTED('Table'))
    var _maxYear=CALCULATE(MAX('Table'[YEAR]),ALLSELECTED('Table'))
    var _value1=CALCULATE(SUM('Table'[REVENUE]),FILTER(ALL('Table'),'Table'[YEAR]=_minYear && 'Table'[CLIENT]<>_getClient && 'Table'[SEGMENT] =_getSegment))
    var _value2=CALCULATE(SUM('Table'[REVENUE]),FILTER(ALL('Table'),'Table'[YEAR]=_maxYear && 'Table'[CLIENT]<>_getClient && 'Table'[SEGMENT] =_getSegment))
return (_value2-_value1)/_value1

 

vxiaotang_0-1635497046622.png

vxiaotang_1-1635497072353.png

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.