Forum Discussion

jalaomar's avatar
jalaomar
Helper IV
3 years ago
Solved

Correct Total Budget Margin Calculation in Table visual

Hi,

 

I have a source data connected to SAP HANA, Direct Query and have some financial data where I calculate the Budget Margin% 

the measures I have created seems to work fine except for the Total Margin% calculation.

calculated column seems not possible due to Direct Query connection.

 

But there are instances in some projects where there is no Sales Price but a Budget cost allocated 

and i would like to exclude these costs from the Total Budget Margin as it impacts the margin% results. Is there a way to fix this issue?

 

These are the measures I am using 

  • Step 1: Total Sales
  • Step 2: Total Budget Cost

 

  • Step 3: Budget Margin

Budget Margin = Sales Price – Budget Cost

 

  • Step 4: Budget%

Budget Margin% = Budget Margin / Sales Price

 

 

 

 

  • Hi , jalaomar 

    I get it that you want to exlcude from the total budget margin is all projects where sales price is 0.

    Here are the steps you can refer to :
    (1)This is my test data :

    (2)We can create two measures :

    Budget Margin = 
    var _t =FILTER( SUMMARIZE( ALLSELECTED('Project') , 'Project'[Product ID] ,"Sales",[Sales Price],"Budget" , [Budget Cost] ) , [Sales] <> BLANK())
    return
    IF(HASONEVALUE('Project'[Product ID]), [Sales Price] - [Budget Cost] ,SUMX(_t,[Sales]-[Budget Cost]))
    Budget Margin% = DIVIDE([Budget Margin],[Sales Price])

    (3)Then we can meet your need , the result is as follows:

    Best Regards,

    Aniya Zhang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

6 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion
    • jalaomar's avatar
      jalaomar
      Helper IV

      Hi,

       

      Just entered my vote!

       

      but just a question, should I create a m_total measure for all measures i have created?

       

      Total sales price

      Total Budget cost

      Budget Margin

       

      BR

      J

  • Hi, jalaomar 

    According to your description, you don't want to calculate the value <0 in the total of [Budget Margin] . Right?

    You can try to use these measures to replace the [Budget Margin] and [Budget Margin%]:

    Budget Margin =
    
     var _t =FILTER( SUMMARIZE( ALL('Project'[Project ID]) , [Project ID],"Budger Margin" , [Sales]-[Budget total]) , [Budger Margin]>0)
    
     return
    
     IF( HASONEVALUE('Project'[Project ID]) , [Sales] - [Budget total] , SUMX(_t , [Budger Margin])
    
    )
    Budget % = IF([Budget Margin] <0 ,BLANK() , DIVIDE([Budget Margin],[Sales]))

    (3)Then we can meet your need , the result is as follows:

     

    Best Regards,

    Aniya Zhang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

    • jalaomar's avatar
      jalaomar
      Helper IV

      Hello,

       

      Not really actually 

      there are cases where Budget Cost is more than the sales price 

       

      so the correct would, to exlcude from the total budget margin is all projects where sales price is 0.

       

      any idea how to manage that?

       

      Thanks!

      • v-yueyunzh-msft's avatar
        v-yueyunzh-msft
        Community Support

        Hi , jalaomar 

        I get it that you want to exlcude from the total budget margin is all projects where sales price is 0.

        Here are the steps you can refer to :
        (1)This is my test data :

        (2)We can create two measures :

        Budget Margin = 
        var _t =FILTER( SUMMARIZE( ALLSELECTED('Project') , 'Project'[Product ID] ,"Sales",[Sales Price],"Budget" , [Budget Cost] ) , [Sales] <> BLANK())
        return
        IF(HASONEVALUE('Project'[Product ID]), [Sales Price] - [Budget Cost] ,SUMX(_t,[Sales]-[Budget Cost]))
        Budget Margin% = DIVIDE([Budget Margin],[Sales Price])

        (3)Then we can meet your need , the result is as follows:

        Best Regards,

        Aniya Zhang

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly