Forum Discussion

Wise1's avatar
Wise1
Helper I
9 years ago

DAX Formula for subtracting

Hello All,

 

I have been trying to figure the following out for the last 2 days without any luck, 

 

Basiclly what iam trying to achieve is 

Client - has allocated 10 hours a month

4 hrs worth of work is generated

 

10-4hrs = 6 hrs remain

The following is what iam working with; 

 

* Direct Query SQL 

 

 

 

 

1. Create a dax formula to combine hours spent on a "client" 

SLAHrsCalculatedPerClient = sla[MeasureTotalTimespentOrg]

 

2. Attempted to make another measure to minus the caculated time (but it doesnt show up) 

SLAHrsMinusFromAllocated = sla[MeasureTotalTimespentOrg]-  "SLA HOURS"

 

 

 

 

however if i manually type the following it minus's the correct amount

SLAHrsCalculatedPerClient = sla[MeasureTotalTimespentOrg]-5 

 

Am i overlooking something with the above, or just not going about it the right way entirely? 

 

i have tried looking at a few other ways of doing this without luck, I hope enough information is provided

 

31 Replies

  • wynhopkins's avatar
    wynhopkins
    Most Valuable Professional

    I think if you type  [SLAHrsCalculatedPerClient] you will get what you need

     

    By typing sla to begin with you are referencing a table column rather than a measure

     

    To get a measure start with a [

     

     

  • wynhopkins's avatar
    wynhopkins
    Most Valuable Professional

    Actually looking at this closer I think you need to use a SUM in your measures

     

     

    SLAHrsTotal = SUM(sla[SLA Hours])

     

    SLAHrsCalculatedPerClient = SUM(sla[MeasureTotalTimespentOrg])

     

     

    SLAHrsMinusFromAllocated = [SLAHrsTotal] - [SLAHrsCalculatedPerClient]

     

     

    • Wise1's avatar
      Wise1
      Helper I

      Thanks for your reply

      Problem is the "SLA Hours" data is pulled directly from SQL as is (it comes up with error when trying to SUM) (i assume its because there is nothing to sum as its data entered) 

       

       

      i have tried to do a "vlookup" of the data but its not giving me the option to type when i try enter the formula, or just something to print the data out to enable me to minus hours entered against it 

       

      IE: 

       

       

      • wynhopkins's avatar
        wynhopkins
        Most Valuable Professional

        Can you convert the SLA Hours to values on import in the Query editor?