Forum Discussion

apelleti's avatar
apelleti
Helper I
3 years ago
Solved

DAX expression question

Hi everyone, 

 

I'm looking for a DAX forumla that will return the column below "Significant Line". If a line contains at least one significant segment (Significant Segment = Yes), then each entry for that line is assigned "Yes" in the column "Significant line". 

 

I tried the formula below which works as a measure, but does not work directly in the table (i.e when clicking "new column" in the table view).

 
SignificantLine = MAXX(FILTER(ALL('Table'),'Table'[Line]=SELECTEDVALUE('Table'[Line])),'Table'[SignificantSegment)
 
Thanks in advance!

 

LineSegmentSignificant SegmentSignificant Line
11YesYes
12NoYes
13NoYes
14NoYes
25YesYes
26YesYes
27YesYes
28YesYes
39NoNo
310NoNo
411YesYes
412NoYes
413YesYes
  • Update like this:

    Column =
    VAR _line = TableName[Line]
    VAR SigSeg =
    CALCULATE(
        MAX(TableName[Significant Segment]),
        TableName[Line] = _line,
        ALL()
    )
    RETURN
    IF(SigSeg="Yes", "Yes", "No")
     
    tried and it worked like this:

8 Replies

  • hi apelleti 

    For calculated column, try like:

    Significant Line =

    VAR _line = [Line]

    VAR SigSeg = 

    CALCULATE(

         MAX([Significant Segment]),

         [Line] = _line

    )

    RETURN

    IF(SigSeg="Yes", "Yes", "No")

    • FreemanZ's avatar
      FreemanZ
      Super User

      Update like this:

      Column =
      VAR _line = TableName[Line]
      VAR SigSeg =
      CALCULATE(
          MAX(TableName[Significant Segment]),
          TableName[Line] = _line,
          ALL()
      )
      RETURN
      IF(SigSeg="Yes", "Yes", "No")
       
      tried and it worked like this:
  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi apelleti 

    you can also use

    SignificantLine =
    IF (
    "Yes"
    IN CALCULATETABLE (
    VALUES ( 'Table'[SignificantSegment] ),
    ALLEXCEPT ( 'Table', 'Table'[Line] )
    ),
    "Yes",
    "No"
    )

     

    or

     

    SignificantLine =
    IF (
    COUNTROWS (
    CALCULATETABLE (
    VALUES ( 'Table'[SignificantSegment] ),
    ALLEXCEPT ( 'Table', 'Table'[Line] )
    )
    ) > 1,
    "Yes",
    "No"
    )