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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Matrix Measure - Show sum of detailed rows on each detailed row

Hello,


I am creating a matrix that shows a list of vessels, and has detail rows showing the various ports that each vessel will be visiting. Each port has an associated region (Americas, Asia, Middle East, Europe/ROW). I have a "Region" slicer that does not have a relationship with the vessel data, but is being used by a measure, "Measure 1", to determine if a given Vessel/Port combination belongs to one of the selected regions. The measure assigns a value of 1 if the port belongs to a selected region, and a value of 0 if it does not.


This is all working fine, but the next step is where my issue lies. If ANY of the ports associated with a vessel belong to one of the selected regions, I want ALL of the ports for that vessel to be displayed in the matrix. My thought was to create a second measure, "Measure 2", that will sum "Measure 1" for each vessel, such that "Measure 2" could be displayed in the matrix alongside each port and still display the "Measure 1" total for the entire vessel. I would then use "Measure 2" as a visual filter in the matrix so that records where "Measure 2" > 0 would be displayed.


Here is an Excel sample showing my desired result:

 

Selected Ports = Americas, Asia   
      
VesselPortMeasure 1Port RegionMeasure 2 - CurrentMeasure 2 - Desired
Vessel 1Texas1Americas15
Vessel 1Ecuador1Americas15
Vessel 1Peru1Americas15
Vessel 1Peru1Americas15
Vessel 1Chile1Americas15
Vessel 2South Korea1Asia17
Vessel 2South Korea1Asia17
Vessel 2South Korea1Asia17
Vessel 2China1Asia17
Vessel 2Singapore1Asia17
Vessel 2Angola0Europe/ROW07
Vessel 2Nigeria0Europe/ROW07
Vessel 3Greece0Europe/ROW04
Vessel 3Italy0Europe/ROW04
Vessel 3Singaport1Asia14
Vessel 3China1Asia1

4

 

 

In the sample above, "Measure 1" correctly identifies when a port belongs to one of the selected regions (Americas, Asia). However, "Measure 2" is not currently working as desired. It seems to simply be duplicating the logic of "Measure 1", however I would like it to represent the sum of "Measure 1" for the vessel as a whole (see "Measure 2 - Desired" column). Here is my DAX for both measures:

 

Measure 1 =
var SelectedRegions = CONCATENATEX(ALLSELECTED(Regions[Region]), Regions[Region], ",")
var str_SelectedRegions = SUBSTITUTE(SelectedRegions, ",", "|")
var str_len = PATHLENGTH(str_SelectedRegions)
var tbl_list = ADDCOLUMNS(
GENERATESERIES(1, str_len),
"table",
PATHITEM(str_SelectedRegions, [Value])
)
var lst = SELECTCOLUMNS(tbl_list, "list", [table])

return

SUMX(
'Voyage Schedule',
if(
'Voyage Schedule'[col_Region_port] in lst,
1,
0
)
)
 
 
Measure 2 =
sumx(
values('Voyage Schedule'[VoyageNumber]),
[Measure 1]
)
1 ACCEPTED SOLUTION
Iamnvt
Continued Contributor
Continued Contributor

hi,

 

I think there is something wrong with your desire result. Eg. if you want to sum of Measure 1 for each Vessel 2, the result should be 5, not 7.

 

if my understanding is correct, then you can use this measure:

new measure 2 = SUMX(ALLEXCEPT(Table1, Table1[Vessel]), [sum of measure 1])

the ALLEXCEPT will ignore all the outer filter from table: port, port regions, except Vessel column, it will sum up the result of Measure 1 for Vessel column only.

 

here is the PBI file:

https://1drv.ms/u/s!Aps8poidQa5zk6pV_kVCZORV97Zz7g

View solution in original post

2 REPLIES 2
Iamnvt
Continued Contributor
Continued Contributor

hi,

 

I think there is something wrong with your desire result. Eg. if you want to sum of Measure 1 for each Vessel 2, the result should be 5, not 7.

 

if my understanding is correct, then you can use this measure:

new measure 2 = SUMX(ALLEXCEPT(Table1, Table1[Vessel]), [sum of measure 1])

the ALLEXCEPT will ignore all the outer filter from table: port, port regions, except Vessel column, it will sum up the result of Measure 1 for Vessel column only.

 

here is the PBI file:

https://1drv.ms/u/s!Aps8poidQa5zk6pV_kVCZORV97Zz7g

Anonymous
Not applicable

Wow, that's exactly what I am looking for. Thank you so much!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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