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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Difference between different different values depending on filter criteria

Hi Power Bi Team,

 

I am Trying to work out this report but i have some difficulties to make this happen.

 

I have this table where this levels are displayed:

 

Fare TypeRouteMonthCompanyLead in fare
RestrictiveXXX-YYYJun-13Company A185.00
RestrictiveXXX-YYYJun-13Company B169.00

 

what I need is the fare difference between A and B if:

 

- Fare type

- Route

- Month

 

are the same. 

 

then I have to display this on a bar chart so the differential is displayed throughout the year. 

 

Let me know if you have any ideas in mind. 

 

thank you

Alberto Smiley Very Happy

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous

In query editor, please pay attention to the bold characters which you can use for your scenario.

Code in advanced editor,

let

    Source = Excel.Workbook(File.Contents("C:\Users\maggiel\Desktop\case\6\6.20\Difference between.xlsx"), null, true),

    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],

    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),

    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Fare Type", type text}, {"Route", type text}, {"Month", type date}, {"Company", type text}, {"Lead in fare", Int64.Type}}),

    #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "CompanyA", each if Text.Contains([Company], "A") then [Lead in fare] else null),

    #"Filled Down" = Table.FillDown(#"Added Conditional Column",{"CompanyA"})

in

#"Filled Down"

 

Then in Data Model View, create a calculated column

differentialA-B = [CompanyA]-[Lead in fare]

 

2.png

3.png

 

Best Regards

Maggie 

View solution in original post

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @Anonymous

In query editor, please pay attention to the bold characters which you can use for your scenario.

Code in advanced editor,

let

    Source = Excel.Workbook(File.Contents("C:\Users\maggiel\Desktop\case\6\6.20\Difference between.xlsx"), null, true),

    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],

    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),

    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Fare Type", type text}, {"Route", type text}, {"Month", type date}, {"Company", type text}, {"Lead in fare", Int64.Type}}),

    #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "CompanyA", each if Text.Contains([Company], "A") then [Lead in fare] else null),

    #"Filled Down" = Table.FillDown(#"Added Conditional Column",{"CompanyA"})

in

#"Filled Down"

 

Then in Data Model View, create a calculated column

differentialA-B = [CompanyA]-[Lead in fare]

 

2.png

3.png

 

Best Regards

Maggie 

Helpful resources

Announcements
Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors