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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
apelleti
Helper I
Helper I

Help with a DAX formula for Power BI measure

Hi everyone! Hoping some can help me with a DAX formula for a measure in Power BI.

 

In this scenario, lines are made up of segments. Lines can contain significant segments. I need a formula that checks if a line contains at least one significant segment and if it does, return the sum of the lengths of the lines that contain significant segments.

 

So in the scenario below, it would be the sum of the lengths of lines 1, 2 and 4:

 

Total Line feet = 10 + 65 + 30 

Total Line feet = 105

 

Any help would be greatly appreciated!

 

Line NameSegment Length (ft)SignificantLine Length (ft) (sum of segments)
12Yes10
12No10
15No10
11No10
210Yes65
215Yes65
220Yes65
220Yes65
33No7
34No7
49Yes30
414No30
47Yes30
1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @apelleti 

 

try to

1)create a measure with this:

SignificantLen=
VAR _table = 
FILTER(
   SUMMARIZE(
         TableName,
         TableName[Line],
         TableName[Significant],
         TableName[Length]
    ),
   TableName[Significant] = "YES"
)
RETURN
SUMX(_table, TableName[Length])
 
2) then plot any visual with this measure.
I tried and it worked like this:
FreemanZ_0-1670632547430.png

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @apelleti ,

I have created a simple sample, please refer to my pbix file to see if it helps you.

Create 3 measures.

Measure = 
MAXX(FILTER(ALL('Table'),'Table'[Line Name]=SELECTEDVALUE('Table'[Line Name])),'Table'[Significant])
Measure 2 = sUMX(FILTER(ALL('Table'),'Table'[Line Name]=SELECTEDVALUE('Table'[Line Name])),'Table'[Segment Length (ft)])

 

SignificantLen = 
var _1=SUMX(FILTER(ALL('Table'),'Table'[Line Name]=SELECTEDVALUE('Table'[Line Name])),'Table'[Segment Length (ft)])
var _2=SUMMARIZE('Table','Table'[Line Name],"aaa",[Measure 2])
var _3=CALCULATE(SUM('Table'[Segment Length (ft)]),FILTER(ALL('Table'),[Measure]="No"))
return
IF(HASONEVALUE('Table'[Line Name])&&[Measure]="Yes",[Measure 2],IF([Measure]="No",BLANK(),SUMX(_2,[aaa])-_3))

vpollymsft_0-1670817782556.png

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

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

apelleti
Helper I
Helper I

Thank you for your reply! I can't seem to get the right numbers. What formula did you use to calculate the line length from the segment lengths?

@apelleti I thought line length is native from your sample data. but it can be calculated.

@FreemanZ 

 

I created it using:

 

Line Length (ft) = CALCULATE(SUM('Table'[Segment Length (ft)]),
         ALLEXCEPT('Table','Table'[Line Name]))
 
Does that seem right to you?
 
Thank you!
FreemanZ
Super User
Super User

hi @apelleti 

 

try to

1)create a measure with this:

SignificantLen=
VAR _table = 
FILTER(
   SUMMARIZE(
         TableName,
         TableName[Line],
         TableName[Significant],
         TableName[Length]
    ),
   TableName[Significant] = "YES"
)
RETURN
SUMX(_table, TableName[Length])
 
2) then plot any visual with this measure.
I tried and it worked like this:
FreemanZ_0-1670632547430.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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