Forum Discussion

Sachy123's avatar
Sachy123
Helper V
5 years ago
Solved

Bottom Lines!

 I am planning to create a report where I need to show various calculations at the bottom of the tables as shown below.

E.g. 

RegionSalesCostsEmployees
APAC600004000100
EMEA300002000200
USA200001000300
Total <TOTAL SALES><MEDIAN COSTS><AVERAGE EMPLOYEES>

 

So , how can I start? shall I create a measure? but then how can I show it on the bottom like as in the table above?

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Sachy123 ,

     

    Based on my test, since for Sales , the total field is sum(Sales), you could use the default summarization type. And For Costs and Employees ,please try the following formula to create measures:

     

    • Method1:
    Costs1 = IF(HASONEVALUE('Table'[Costs]),SUM('Table'[Costs]),MEDIAN('Table'[Costs]))
    Employees1 = IF(HASONEVALUE('Table'[Employees]),SUM('Table'[Employees]),AVERAGE('Table'[Employees]))
    • Method2:
    Costs2 = IF(ISINSCOPE('Table'[Region]),SUM('Table'[Costs]),MEDIAN('Table'[Costs]))
    Employees2 = IF(ISINSCOPE('Table'[Region]),SUM('Table'[Employees]),AVERAGE('Table'[Employees]))

     The final output is shown below:

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

2 Replies

  • Sachy123 yes you need to create measure and check in the measure if you are at the total line, and one way to do this is by using HASONEVALUE function:

     

    Example measure:

     

    Test Measure =
    //in this example, if it is on total line it will calculate average otherwise sum
    IF ( HASONEVALUE ( Table[Region] ), SUM ( Table[Costs] ), AVERAGE ( Table[Costs] ) ) )
    

     

    Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Sachy123 ,

     

    Based on my test, since for Sales , the total field is sum(Sales), you could use the default summarization type. And For Costs and Employees ,please try the following formula to create measures:

     

    • Method1:
    Costs1 = IF(HASONEVALUE('Table'[Costs]),SUM('Table'[Costs]),MEDIAN('Table'[Costs]))
    Employees1 = IF(HASONEVALUE('Table'[Employees]),SUM('Table'[Employees]),AVERAGE('Table'[Employees]))
    • Method2:
    Costs2 = IF(ISINSCOPE('Table'[Region]),SUM('Table'[Costs]),MEDIAN('Table'[Costs]))
    Employees2 = IF(ISINSCOPE('Table'[Region]),SUM('Table'[Employees]),AVERAGE('Table'[Employees]))

     The final output is shown below:

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