Forum Discussion

VulcanPromance's avatar
6 years ago
Solved

Best Practice Question

Hi.. I struggle alot with creating a max variable I can use for calculations and slicing.

 

The idea is to show the yearly price for each Bundle where you only pay for the highest number of License (using that license price) within the bundle. When I click on a country (slicing) it should only show the max for that country.

 

Later in the model I will use the yearly cost to calculate shared costs that are  percentage based on country yearly cost vs total yearly cost. 

 

I tried countless of ways of doing this. But I cant seem to get a consistent variable to use. I calculated max both as columns in the price table and as a measure to use. But somewhere down the line something is allways messed up, and the culprit seems to be the way I calculated the max value which dont work in other calculations.

 

So.. is it best to use calculated columns to find the max, or calculated measure? Could someone please show me the proper way?
https://1drv.ms/u/s!AsOQeIMpZu5M9lgSKWorfDCabCrZ?e=3MMB1K

 

 

  • MFelix's avatar
    MFelix
    6 years ago

    Hi VulcanPromance ,

     

    To what I can understand here you issue is based on the calculation of the percentage of Yearly costs per country this can be achieve by making the following measures:

     

    Monthly Price = 
    VAR temp_Table =
        SUMMARIZE (
            'Price Table';
            'Price Table'[Bundle Name];
            'Price Table'[Price];
            "Users"; DISTINCTCOUNT ( Licenses[UserID] )
        )
    RETURN
        SUMX ( temp_Table; 'Price Table'[Price] * [Users] )
    
    Yearly Price = [Monthly Price] * 12

     

    I'm assuming the Yearly is just multiplyig by 12 months.

     

    Then you need to calculate the percentage of costs per country selected:

    % per Country = [Yearly Price] / CALCULATE([Yearly Price];all(Employees[Country]))

    If you have a country table that should be based on that table and not employees table.

     

    Now just make the measures for the Shared Costs:

    Shared_Costs = SUM('Cost Table'[Cost]) // Just used as a auxiliary calculation
    
    Shared_Costs_Selected_Countries = [% per Country] * [Shared_Costs]
    
    Markup 5% = [Shared_Costs_Selected_Countries] * 0,05
    
    Overhead 10% = [Shared_Costs_Selected_Countries] * 0,1
    
    Fee 3% = [Shared_Costs_Selected_Countries] * 0,03
    
    BO4 Reporting 12% = [Shared_Costs_Selected_Countries] * 0,12
    
    Total Shared Costs = [Shared_Costs_Selected_Countries]+Measure_Table[Markup 5%]+[Overhead 10%]+[Fee 3%]+[BO4 Reporting 12%]

     

    This values will give you the calculation for the shared costs now you only need to sum the value of the last measure with the Yearly costs and you are all set:

    Total Costs Per country = [Yearly Price] + [Total Shared Costs]

     

    Check the image below and the PBIX file attach.

    Any questions please tell me.

     

     

  • MFelix's avatar
    MFelix
    6 years ago

    Hi VulcanPromance ,

     

    Add the following measure to your calculation:

    Count of users =
    CALCULATE (
        MAXX (
            SUMMARIZE (
                'Price Table';
                'Price Table'[Bundle Name];
                'Price Table'[License Name];
                "@User_Count"; DISTINCTCOUNT ( Licenses[UserID] )
            );
            [@User_Count]
        );
        ALLEXCEPT ( 'Price Table'; 'Price Table'[Bundle Name] )
    )

     

    Now just need to redo the Montlhy price and everything else will calculate accordingly:

    Monthly Price = 
    VAR temp_Table =
        SUMMARIZE (
            'Price Table';
            'Price Table'[Bundle Name];
            'Price Table'[Price];
            "Users"; [Count of users]
        )
    RETURN
        SUMX ( temp_Table;'Price Table'[Price] * [Users])

    Just added the Count of Users in your measure. There is a small difference but believe is rounding.

     

    Check result attach.

     

14 Replies

  • Hi VulcanPromance ,

     

    Not really sure what you are looking for.

     

    Can you please specify with examples what you need in terms of:

    • Yearly price for each Bundle where you only pay for the highest number of License (using that license price)
    • Click on a country (slicing) it should only show the max for that country
    • Later in the model I will use the yearly cost to calculate shared costs
    • Percentage based on country yearly cost vs total yearly cost

     

    Not really sure about what is the number you need for the calculations,is it based on the value times number of users? what is the result basically.

     

    • VulcanPromance's avatar
      VulcanPromance
      Helper II

      Yeah.. this is basically the result I want

       

       

      And when I click on Norway (slicer)

      I get these numbers instead

       

      and I need to be able to drill down on license names in the license visual..

    • VulcanPromance's avatar
      VulcanPromance
      Helper II

      actually this didnt solve my question.. it autosolved it it seems.  MFelix  do you have more insight?

      • MFelix's avatar
        MFelix
        Super User

        Hi VulcanPromance ,

         

        To what I can understand here you issue is based on the calculation of the percentage of Yearly costs per country this can be achieve by making the following measures:

         

        Monthly Price = 
        VAR temp_Table =
            SUMMARIZE (
                'Price Table';
                'Price Table'[Bundle Name];
                'Price Table'[Price];
                "Users"; DISTINCTCOUNT ( Licenses[UserID] )
            )
        RETURN
            SUMX ( temp_Table; 'Price Table'[Price] * [Users] )
        
        Yearly Price = [Monthly Price] * 12

         

        I'm assuming the Yearly is just multiplyig by 12 months.

         

        Then you need to calculate the percentage of costs per country selected:

        % per Country = [Yearly Price] / CALCULATE([Yearly Price];all(Employees[Country]))

        If you have a country table that should be based on that table and not employees table.

         

        Now just make the measures for the Shared Costs:

        Shared_Costs = SUM('Cost Table'[Cost]) // Just used as a auxiliary calculation
        
        Shared_Costs_Selected_Countries = [% per Country] * [Shared_Costs]
        
        Markup 5% = [Shared_Costs_Selected_Countries] * 0,05
        
        Overhead 10% = [Shared_Costs_Selected_Countries] * 0,1
        
        Fee 3% = [Shared_Costs_Selected_Countries] * 0,03
        
        BO4 Reporting 12% = [Shared_Costs_Selected_Countries] * 0,12
        
        Total Shared Costs = [Shared_Costs_Selected_Countries]+Measure_Table[Markup 5%]+[Overhead 10%]+[Fee 3%]+[BO4 Reporting 12%]

         

        This values will give you the calculation for the shared costs now you only need to sum the value of the last measure with the Yearly costs and you are all set:

        Total Costs Per country = [Yearly Price] + [Total Shared Costs]

         

        Check the image below and the PBIX file attach.

        Any questions please tell me.