Create a mesure with condition

  • Create a mesure with condition

    Posted by DSC Communities on July 2, 2020 at 3:11 am
    • Robert NGUYEN

      Member

      July 2, 2020 at 3:11 AM

      Hi all,

      Hope you can help me out with this one.

      I’m trying to create a mesure with a condition but I’m failed.
      It seems very simple at first but it is not !!

      Amount calculated is If status is R then Store AmountĀ  Else Amount

      Thanks in advance

      ——————————
      Boby

      ——————————

    • colin mcilwain

      Member

      July 2, 2020 at 3:53 AM

      Hi ,

      try this.

      Amount Calculated = 
      var __Store=SELECTEDVALUE('Table'[Store])
      var __Status=SELECTEDVALUE('Table'[Status])
      var __Tot_R=calculate(sumx(ALLSELECTED('Table'),[Amount]),'Table'[Store]=__Store)
      var __Tot_T=sum('Table'[Amount])
      return if(__Status="R",__Tot_R,__Tot_T)?

      ?


      Colin.

      ——————————
      colin mcilwain
      Lead Process Specialist
      ——————————
      ——————————————-

    • Robert NGUYEN

      Member

      July 2, 2020 at 4:45 AM

      Hi Colin,

      Which table i have to put here ?

      ALLSELECTED('Table')?

      Thank you

      ——————————
      Boby
      ——————————
      ——————————————-

    • colin mcilwain

      Member

      July 2, 2020 at 5:13 AM

      Hi ,
      replace ‘Table’ with the name of your table.

      Amount Calculated = 
      var __Store=SELECTEDVALUE('MyTableName'[Store])
      var __Status=SELECTEDVALUE('MyTableName'[Status])
      var __Tot_R=calculate(sumx(ALLSELECTED('MyTableName'),[Amount]),'MyTableName'[Store]=__Store)
      var __Tot_T=sum('MyTableName'[Amount])
      return if(__Status="R",__Tot_R,__Tot_T)

      Colin.?

      ——————————
      colin mcilwain
      Lead Process Specialist
      ——————————
      ——————————————-

    • Robert NGUYEN

      Member

      July 2, 2020 at 5:52 AM

      Hi Colin,

      each colum of my table is a tablename distinct :
      Store is store
      Name is User
      Status is User
      Amount is revenue
      amount calculated is a mesure of Amount.

      My formula :
      amount]calculated =
      var __Store = SELECTEDVALUE(Store[StoreName])
      var __Status = SELECTEDVALUE(User[Status])
      var __Tot_R = calculate(sumx(ALLSELECTED(User), [total amount] ),Store[StoreName]= __Store)
      var __Tot_T = [total amount]
      return if (__Status =”R”, __Tot_R, __Tot_T)

      butĀ  :

      ——————————
      Boby
      ——————————
      ——————————————-

    • Robert NGUYEN

      Member

      July 2, 2020 at 7:10 AM

      Hi Colin,

      It’s working !! my bad.
      Your formula was ok.

      Thank you very much for your help. Appreciated

      ——————————
      Boby
      ——————————
      ——————————————-

    DSC Communities replied 5 years, 3 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

The discussion ‘Create a mesure with condition’ is closed to new replies.

Start of Discussion
0 of 0 replies June 2018
Now

Welcome to our new site!

Here you will find a wealth of information created for peopleĀ  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!