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
Oleg222
Helper II
Helper II

Measures for certain branches

Hello everybody.
There is a list of branches, different indicators are calculated for them. Is it possible to make certain indicators are calculated for certain branches? When a branch was selected by the slicer, were the lines with measures for that branch displayed? I tried to KEEPFILTERS but it leaves the line with the indicator empty, but it needs to disappear.

For example, part of a big table

BranchSum
Branch1, sales   100
Branch1, sales   150
Branch2, sales   200
Branch2, sales   250
Branch3, sales   110
Branch1, expense   50
Branch1, expense   60
Branch2, expense80
Branch3, expense   35

 

Result - sales measure for 3 should not be considered, only expense

MeasuresSum
Branch1    
   Sales   250
   Expense   110
Branch2    
   Sales   450
   Expense   80
Branch3    
   Expense   35

 

 

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

First you should split the Branch column into 2: one for Branch and the other for sales/expenses. You can Use this code in Power Query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcipKzEvOMNRRKE7MSS1WUFBQ0lEyNDBQitXBIWeKLGeEImdkgEcORZ8xqpmGaPalVhSk5hWnQmRN8UmaodkIlQTKWKDZh6LN2FQpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Branch = _t, Sum = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Branch", type text}, {"Sum", Int64.Type}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Branch", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Branch.1", "Branch.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Branch.1", type text}, {"Branch.2", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Branch.1", "Branch"}, {"Branch.2", "Type"}}),
    #"Trimmed Text" = Table.TransformColumns(#"Renamed Columns",{{"Type", Text.Trim, type text}}),
    #"Cleaned Text" = Table.TransformColumns(#"Trimmed Text",{{"Type", Text.Clean, type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Cleaned Text", each true)
in
    #"Filtered Rows"

To get this structure:

Split column.JPG

 Ideally you should then create Dimension Tables for Branch and Type (recommended). This is how the model looks:

model.JPG

 

Then, with these measures:

Sum Amount = SUM(FactTable[Sum])
Exc br3 sales =
SUMX (
    FactTable,
    CALCULATE (
        IF (
            MAX ( 'Dim Branch'[dBranch] ) = "Branch3"
                && MAX ( 'Dim Type'[dType] ) = "sales",
            BLANK (),
            [Sum Amount]
        )
    )
)

You will get the following:

result.JPG

 

I've attached the sample PBIX file

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

3 REPLIES 3
PaulDBrown
Community Champion
Community Champion

First you should split the Branch column into 2: one for Branch and the other for sales/expenses. You can Use this code in Power Query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcipKzEvOMNRRKE7MSS1WUFBQ0lEyNDBQitXBIWeKLGeEImdkgEcORZ8xqpmGaPalVhSk5hWnQmRN8UmaodkIlQTKWKDZh6LN2FQpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Branch = _t, Sum = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Branch", type text}, {"Sum", Int64.Type}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Branch", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Branch.1", "Branch.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Branch.1", type text}, {"Branch.2", type text}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Branch.1", "Branch"}, {"Branch.2", "Type"}}),
    #"Trimmed Text" = Table.TransformColumns(#"Renamed Columns",{{"Type", Text.Trim, type text}}),
    #"Cleaned Text" = Table.TransformColumns(#"Trimmed Text",{{"Type", Text.Clean, type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Cleaned Text", each true)
in
    #"Filtered Rows"

To get this structure:

Split column.JPG

 Ideally you should then create Dimension Tables for Branch and Type (recommended). This is how the model looks:

model.JPG

 

Then, with these measures:

Sum Amount = SUM(FactTable[Sum])
Exc br3 sales =
SUMX (
    FactTable,
    CALCULATE (
        IF (
            MAX ( 'Dim Branch'[dBranch] ) = "Branch3"
                && MAX ( 'Dim Type'[dType] ) = "sales",
            BLANK (),
            [Sum Amount]
        )
    )
)

You will get the following:

result.JPG

 

I've attached the sample PBIX file

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

Please provide sample data or a PBIX file, and a depiction of the expected outcome





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown I changed it

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.