Forum Discussion

Sri57's avatar
Sri57
Frequent Visitor
2 years ago
Solved

DAX measure

I am new to DAX and Iam trying to convert the below column to measure, but somehow didnot found the luck, can someone help me on this

IF ('Table A'[Ship Date] = BLANK (),BLANK (),
   IF ('Table A'[Order Creation Date] = BLANK (),BLANK (),
     IF ('Table A'[Ship Date] - 'Table A'[Order Creation Date] < 0,-1,
          'Table A'[Ship Date] - 'Table A'[Order Creation Date])))

TIA

  • Hi, Sri57 

    wrap your column name in MIN(), MAX() 
    use some_bih code with MIN() or MAX()

     

    like below

    measure =
    IF (
    ISBLANK ( min('Table A'[Ship Date] )),
    BLANK (),
    IF (
    ISBLANK ( min('Table A'[Order Creation Date] )),
    BLANK (),
    IF (
    DATEDIFF ( min('Table A'[Order Creation Date]), min('Table A'[Ship Date]), DAY ) < 0,
    -1,
    DATEDIFF ( min('Table A'[Order Creation Date]), min('Table A'[Ship Date]), DAY )
    )
    )
    )

7 Replies

  • Dangar332's avatar
    Dangar332
    Icon for Resident Rockstar rankResident Rockstar

    Hi, Sri57 

    wrap your column name in MIN(), MAX() 
    use some_bih code with MIN() or MAX()

     

    like below

    measure =
    IF (
    ISBLANK ( min('Table A'[Ship Date] )),
    BLANK (),
    IF (
    ISBLANK ( min('Table A'[Order Creation Date] )),
    BLANK (),
    IF (
    DATEDIFF ( min('Table A'[Order Creation Date]), min('Table A'[Ship Date]), DAY ) < 0,
    -1,
    DATEDIFF ( min('Table A'[Order Creation Date]), min('Table A'[Ship Date]), DAY )
    )
    )
    )
  • some_bih's avatar
    some_bih
    Icon for Community Champion rankCommunity Champion

    Hi Sri57 

    Try below (helped with AI)
    Measure =
    IF (
    ISBLANK ( 'Table A'[Ship Date] ),
    BLANK (),
    IF (
    ISBLANK ( 'Table A'[Order Creation Date] ),
    BLANK (),
    IF (
    DATEDIFF ( 'Table A'[Order Creation Date], 'Table A'[Ship Date], DAY ) < 0,
    -1,
    DATEDIFF ( 'Table A'[Order Creation Date], 'Table A'[Ship Date], DAY )
    )
    )
    )

    • Sri57's avatar
      Sri57
      Frequent Visitor

      it is getting error like cannot find name under [Ship Date] and [Order Creation Date] columns when I convert it to measure

  • bhelou's avatar
    bhelou
    Icon for Responsive Resident rankResponsive Resident

    try this : 


    Measure =
    IF (
    ISBLANK('Table A'[Ship Date]) || ISBLANK('Table A'[Order Creation Date]),
    BLANK(),
    IF (
    'Table A'[Ship Date] - 'Table A'[Order Creation Date] < 0,
    -1,
    'Table A'[Ship Date] - 'Table A'[Order Creation Date]
    )
    )

    • Sri57's avatar
      Sri57
      Frequent Visitor

      it is getting error like cannot find name under [Ship Date] and [Order Creation Date] columns when I try this

  • bhelou's avatar
    bhelou
    Icon for Responsive Resident rankResponsive Resident

    Hi , kindly share a sample of the Pbix file