cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
marial16
Helper II
Helper II

Add calculated Row in table

Hallo, 

i import 3 tables from SP to help me create a KPI graph

Can i add a row at the table in BI to calculate (division) of 2 rows above? (Last Row)

 

Example

Own Staff Contractor
157171
141119
0.8980.696
1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @marial16 

You could create measures and change the Total field to the division you want.

 

Like this:

_Own Staff = 
    IF(
        ISINSCOPE('Table'[Index]),SUM('Table'[Own Staff ]),
        DIVIDE(
            CALCULATE(SUM('Table'[Own Staff ]),FILTER(ALL('Table'),'Table'[Index]=MAX('Table'[Index]))),
            CALCULATE(SUM('Table'[Own Staff ]),FILTER(ALL('Table'),'Table'[Index]=MAXX(FILTER(ALL('Table'),'Table'[Index]<MAX('Table'[Index])),[Index])))
        )
    )

 

Result:

vangzhengmsft_1-1636959842868.png

Please refer to the attachment below for details. Hope this helps.

 

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

 

View solution in original post

9 REPLIES 9
v-angzheng-msft
Community Support
Community Support

Hi, @marial16 

 

This does not work when there are more rows in the table, and new rows cannot be added row by row. This is not the way power bi works. You can create a measure to display it next to it. If you can accept the display by row, you can turn on show value on the row.

vangzhengmsft_1-1637746894380.png

Yes, you can use an Excel file that already contains calculations, and you can choose to import the calculations of the model in the import feature.

vangzhengmsft_2-1637747020247.png

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

 

v-angzheng-msft
Community Support
Community Support

Hi, @marial16 

You could create measures and change the Total field to the division you want.

 

Like this:

_Own Staff = 
    IF(
        ISINSCOPE('Table'[Index]),SUM('Table'[Own Staff ]),
        DIVIDE(
            CALCULATE(SUM('Table'[Own Staff ]),FILTER(ALL('Table'),'Table'[Index]=MAX('Table'[Index]))),
            CALCULATE(SUM('Table'[Own Staff ]),FILTER(ALL('Table'),'Table'[Index]=MAXX(FILTER(ALL('Table'),'Table'[Index]<MAX('Table'[Index])),[Index])))
        )
    )

 

Result:

vangzhengmsft_1-1636959842868.png

Please refer to the attachment below for details. Hope this helps.

 

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

 

I finally managed to create the calculated row, however i was wondering if this solution would work if i had more rows in the same table or is it a best practice to create another table?

example :

Own Staff Contractors 
157171
141119
0.8980.696
  
  
284163
1.8090.953

 

where 1.809 is the result of 284 / 157

And a last question of mine would be if i can use an excel file (calculations included) in Power BI without having to create all those measures. 

I had decided to organise the data in SharePoint Lists. However i am not sure if it is the best practice.

Thank you

Ok i manged to add an index column, but i am getting an error when i check the measures and try to create the table visualization:

"The function SUM cannot work with values of type string"

In the Sharepoint list the column type is number.

What am i missing?

Hi, @marial16 


I am adding an index column in Power Query. If the column type is not numeric, then you can change the type to numeric in PowerQuery or on the desktop. Then the SUM function will work properly.

vangzhengmsft_0-1637732825491.png

vangzhengmsft_1-1637732979020.png

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng


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

Hallo, and thank you for your response and example given,

i was trying to implement this and i am not sure how you created the index. 

it is not a measure i see. 

marial16_0-1637578415372.png

 

 

PaulDBrown
Super User
Super User

Ideally you should do this with a matrix visual and using measures (using show measures on rows under "Values" in the formatting pane), which will of course make the data dynamic.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






amitchandak
Super User
Super User

@marial16 , if you want to add in visual table I doubt you can do that

 

The workaround is to create data tables and append them. But they will not take slicer values



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

I have no idea how to do that,

 

any links or documentation that you could suggest? 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors