Forum Discussion

en_90's avatar
en_90
Frequent Visitor
2 years ago
Solved

Convert Measure to Column

Hello,

 

I've created a measure for comparing sales order IDs from the latest two dates (today and yesterday) in my data set. I'm comparing the two dates to see which sales orders were new, removed or carried over day to day (latest two dates). This works as a measure but I need to convert it into a column but I am unable to.

 

Any help on convertting this into a column is appreciated!

 

Measure code:

 

SO_CAT =
  VAR __TodaySO = COUNTROWS(FILTER('TableTop2',[RUN_DATE]=TODAY()))
  VAR __TotalSO = COUNTROWS(SUMMARIZE('TableTop2',[RUN_DATE]))
RETURN
  SWITCH(TRUE(),
    __TodaySO >= 1 && __TotalSO = 1,"NEW",
    __TodaySO >= 1 && __TotalSO > 1,"EXISTING",
    "REMOVED"
  )

 

*The RUN_DATE column is the two dates that I'm comparing (today and yesterday).

  •  

     

    Same = COUNTROWS(INTERSECT('TODAY',YESTERDAY))
    Removed = countrows(except(YESTERDAY,'TODAY'))
    Added = COUNTROWS(EXCEPT('TODAY',YESTERDAY))

     

     

7 Replies

  • Any particular reason for  not using EXCEPT and INTERSECT, the functions designed for this?

  • Hi en_90 ,

     

    You can try indexing logic with custom column -

    SO_CAT =

      VAR __TodaySO = 

          COUNTROWS(

            FILTER(

              'TableTop2', 

              [RUN_DATE] = TODAY()

            )

          )

      VAR __TotalSO = 

          COUNTROWS(

            SUMMARIZE(

              'TableTop2', 

              'TableTop2'[RUN_DATE]

            )

          )

      VAR __IndexSO = 

          RANKX(

            'TableTop2', 

            'TableTop2'[RUN_DATE], 

            , ASC, 

            DENSE

          ) 

    RETURN

      SWITCH(TRUE(),

        __TodaySO >= 1 && __IndexSO = 1, "NEW",

        __TodaySO >= 1 && __IndexSO > 1, "EXI

    STING",

        "REMOVED"

     

    I hope it will be helpful.

     

    Thanks,

    Sai Teja 

      )