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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
hbirk
Frequent Visitor

Line chart where only one item is broken down by legend

Hi!

 

I am working on a project where I am trying to show contracts in a market compared to the rates in the given market. The market has a rate which is a continuos line. The market is made up of contracts which have a fixed rate for the contract period. I want to break down how the individual contracts are priced compared to the market rate like this:

hbirk_0-1677401521984.png

 

Here the yellow line is the market rate, and the two horizontal lines are two contracts for a given contractor. To achieve this I have overlaid two graphs and made one transparet, but I would obviously like to have a single graph for it to behave correctly.

 

For plotting the contracts, I need to add 'ContractID' as legend field for the two contracts to not connect. If I don't, the contracts connect like this, something I don't want:

hbirk_1-1677401795568.png

 

Does anyone know a way I can achieve this in the same graph? Since you can only add one field to the y-axis while using legend, I would guess I would have to create a measure for the plotting the contracts and breaking them down by legend using DAX. Can anyone help with this?

 

Here is a link to a pbix file with what I am trying to achieve, only in two separate graphs.

https://drive.google.com/file/d/1J8w6hwIiNDyxFI498dzni_lvdGmlWtwL/view?usp=sharing

 

1 ACCEPTED SOLUTION
pi_eye
Resolver IV
Resolver IV

Hi @hbirk , there are couple of ways to achieve this.

 

The line chart can either "recognise" multiple measure expressions (multiple measures for the y axis), or one measure split up different ways .

If you have two measures, but one needs to be split up and the other doesn't, it can't tell which to make the legend and which to keep as is.

 

Depending on how big your dataset is, you can appeal to both ways that the line chart can be configured as thus:

 

1) Union the tables into one flat table with a "all" contract ID representing the market rate:

Here I have unioned the tables using DAX, but this can also be achieved using M Query:

Dax Expression:

Unioned table = UNION(  SELECTCOLUMNS( FixtureRate,"U Date",FixtureRate[Date], "U ContractID",FixtureRate[ContractID],  "U Rate", FixtureRate[FixtureRate]),
                        SELECTCOLUMNS('Rate',"U Date",'Rate'[Date]          ,   "U ContractID","Market",                   "U Rate", 'Rate'[Rate])
                        )
Resulting table:
pi_eye_1-1677411415733.png

 

This is then very easily turned into a line chart using the contract ID as a legend and sum (or average) rate as the Y axis:

pi_eye_2-1677411471037.png

 

 

 

2) One measure per contract - 3 measures in total including the market rate

This, while easier to spin up will be counter productive in the long run, as you will have to keep adding measures each time you need to add a contract. However it is very quick to do if you need something "now".

These measures are added to the Fixture rate table

Fixture Rate 1053 = CALCULATE(sum(FixtureRate[FixtureRate]),FixtureRate[ContractID]=1053)
Fixture Rate 2019 = CALCULATE(sum(FixtureRate[FixtureRate]),FixtureRate[ContractID]=2019)

 

Resulting chart - with market rate just "dropped" in as sum:

pi_eye_3-1677411661982.png

 

 

Hope this helps!

 

Pi

 

 

 

 

 

 

 

View solution in original post

2 REPLIES 2
pi_eye
Resolver IV
Resolver IV

Hi @hbirk , there are couple of ways to achieve this.

 

The line chart can either "recognise" multiple measure expressions (multiple measures for the y axis), or one measure split up different ways .

If you have two measures, but one needs to be split up and the other doesn't, it can't tell which to make the legend and which to keep as is.

 

Depending on how big your dataset is, you can appeal to both ways that the line chart can be configured as thus:

 

1) Union the tables into one flat table with a "all" contract ID representing the market rate:

Here I have unioned the tables using DAX, but this can also be achieved using M Query:

Dax Expression:

Unioned table = UNION(  SELECTCOLUMNS( FixtureRate,"U Date",FixtureRate[Date], "U ContractID",FixtureRate[ContractID],  "U Rate", FixtureRate[FixtureRate]),
                        SELECTCOLUMNS('Rate',"U Date",'Rate'[Date]          ,   "U ContractID","Market",                   "U Rate", 'Rate'[Rate])
                        )
Resulting table:
pi_eye_1-1677411415733.png

 

This is then very easily turned into a line chart using the contract ID as a legend and sum (or average) rate as the Y axis:

pi_eye_2-1677411471037.png

 

 

 

2) One measure per contract - 3 measures in total including the market rate

This, while easier to spin up will be counter productive in the long run, as you will have to keep adding measures each time you need to add a contract. However it is very quick to do if you need something "now".

These measures are added to the Fixture rate table

Fixture Rate 1053 = CALCULATE(sum(FixtureRate[FixtureRate]),FixtureRate[ContractID]=1053)
Fixture Rate 2019 = CALCULATE(sum(FixtureRate[FixtureRate]),FixtureRate[ContractID]=2019)

 

Resulting chart - with market rate just "dropped" in as sum:

pi_eye_3-1677411661982.png

 

 

Hope this helps!

 

Pi

 

 

 

 

 

 

 

hbirk
Frequent Visitor

Thank you!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.