Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Obeybe
Frequent Visitor

Calculate the total number of views & likes per topic

Hi everyone,

I'm new in Power BI and I'm wondering if I can achieve the following.

I want to calculate the total number of views & likes for pages in three different language.
The goal is to count the number of views per topic, we use 3 pages per topic, one page per language.
I have a table with:

Colunm "ViewLifeTime" numbers of views per page

Colunm "Likes" numbers of likes per page

Colunm "UniqueID0" Default language page ID
Colunm "OData__SPTranslationSourceItemId" contain the translated page ID with the default language page ID

 

Can someone explain how I can calculate the three pages views number in a new colunm.

UniqueId0OData__SPTranslationSourceItemIdViewsLifeTimeTitleLanguageViewsRecentUniqueUsersViewsLifeTimeUniqueUsersLikesCommentsYearQuarterMonthDay
{72C5881A-DAC9-425F-B0DC-544B8895D737}{5A5FC4A1-4361-4B88-A49D-E767620D9383}21« Les Netnologues » fête ses 10 ans !fr114002024Qtr 4December19
{E35F151E-3C2E-4C6D-8C65-281F307C2E00}{5A5FC4A1-4361-4B88-A49D-E767620D9383}265De Netweters viert z’n 10de verjaardag!nl22211802024Qtr 4December19
{5A5FC4A1-4361-4B88-A49D-E767620D9383}116‘De Netweters’ celebrates its 10th anniversary!en1105202024Qtr 4December19

 

7 REPLIES 7
Sahir_Maharaj
Super User
Super User

Hello @Obeybe,

 

Can you please try the following:

 

1. Calculate the total views

Total Views Per Topic = 
VAR CurrentTopic = SELECTEDVALUE('Table'[UniqueID0])
RETURN
CALCULATE(
    SUM('Table'[ViewsLifeTime]),
    FILTER(
        'Table',
        'Table'[UniqueID0] = CurrentTopic || 'Table'[OData__SPTranslationSourceItemId] = CurrentTopic
    )
)

2. Calculate the total likes

Total Likes Per Topic = 
VAR CurrentTopic = SELECTEDVALUE('Table'[UniqueID0])
RETURN
CALCULATE(
    SUM('Table'[Likes]),
    FILTER(
        'Table',
        'Table'[UniqueID0] = CurrentTopic || 'Table'[OData__SPTranslationSourceItemId] = CurrentTopic
    )
)

Hope this helps.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Hi Sahir,
Thank you for the solution but because my columns "UniqueID0" & "OData__SPTranslationSourceItemId" are not "Numbers" I receive following error.

Obeybe_0-1736751884921.png

 

Best regards

Obeybe

 

v-zhouwen-msft
Community Support
Community Support

Hi danextian ,thanks for the quick reply, I'll add more.

Hi @Obeybe ,

If I have misunderstood, please show the expected results as a picture.

Creating Calculated Columns with the “SUM” Function.

SUM function (DAX) - DAX | Microsoft Learn

Total views = SUM('Table'[ViewsLifeTime])
Total likes = SUM('Table'[Likes])

vzhouwenmsft_0-1736474492276.png

 

Best Regards

 

@v-zhouwen-msft ,
Thank you for the quick reply.
When I try to use the "SUM" function, this error pops up.

Obeybe_0-1736511395865.png

For your understanding what I want to get the total views per topic.
We have three pages per topic, and I want to combine the views in a new column.
Example:

Topic 1, each version is a different page.
8 colleagues show their warm-hearted commitment at our Winter Market (ENG version)
8 collega’s tonen hun warm hart op onze Wintermarkt (Dutch version)

8 collègues témoignent de leur générosité lors de notre Marché d'hiver (French version)

 

Topic 2
Adjustments to hospitalization insurance as of January 1, 2025 (ENG version)

Aanpassingen hospitalisatieverzekering vanaf 1 januari 2025 (Dutch version)

Adaptation de l'assurance hospitalisation à partir du 1er janvier 2025 (French version)
In the table below you can see that the data in the "UniqueID0" column the same is as the data in the "OData__SPTranslationSourceItemId" column.
I presume that those columns the filter must be to count the amount of views for all the pages per topic.

UniqueId0OData__SPTranslationSourceItemIdViewsLifeTimeSum of TotalViewsLifeTimeTitleLanguageViewsRecentUniqueUsersViewsLifeTimeUniqueUsersLikesCommentsYearQuarterMonthDay
{66ACC9E1-6ECB-4856-A916-7D15B16768E6} 5522288 colleagues show their warm-hearted commitment at our Winter Marketen116472712024Qtr 4December19
{B2319220-31EC-4C4E-B25D-2F8A58F7ADB3}{66ACC9E1-6ECB-4856-A916-7D15B16768E6}9382288 collega’s tonen hun warm hart op onze Wintermarktnl1837091702024Qtr 4December19
{587AB83E-33DF-41F5-A7BB-21A483D8C7CA}{66ACC9E1-6ECB-4856-A916-7D15B16768E6}482288 collègues témoignent de leur générosité lors de notre Marché d'hiverfr1035102024Qtr 4December19
{0FE8C140-B202-45B7-838D-890FBD7721C4}{A841E6C7-5720-431B-A9A4-7A1F9B7A4A26}2228Aanpassingen hospitalisatieverzekering vanaf 1 januari 2025nl11002024Qtr 4December19
{DFD580FF-6306-4CDB-9E28-617AD163771E}{A841E6C7-5720-431B-A9A4-7A1F9B7A4A26}1228Adaptation de l'assurance hospitalisation à partir du 1er janvier 2025fr11002024Qtr 4December19
{A841E6C7-5720-431B-A9A4-7A1F9B7A4A26} 3228Adjustments to hospitalization insurance as of January 1, 2025en11002024Qtr 4December19
{BA31D097-46FD-470A-A240-527B0489EC45}{34EC9B61-E3BD-4C14-856B-FD17C1F59F86}121228BASE lance des pop-up stores en Wallonie : un nouveau concept au service de l’expérience clientfr4731532024Qtr 4December19
{4F97FF35-1FB9-40C7-8BFD-72C2405C7912}{34EC9B61-E3BD-4C14-856B-FD17C1F59F86}343228BASE lanceert nieuwe klantervaring met pop-up shopsnl72861302024Qtr 4December19
{34EC9B61-E3BD-4C14-856B-FD17C1F59F86} 220228BASE launches new customer experience with pop-up shopsen13189602024Qtr 4December19


Best regards
Obeybe

Ensure that the column you are trying to sum is type number. Your screenshot shows it is a string.










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi danextian,
Thank you for the tip.
I cannot change te type of the column "UniqueID0" to number because this column contain also letters.
Exemple: {65670018-2957-4B24-967C-1AB666FBDB69}

danextian
Super User
Super User

Hi @Obeybe 

 

Can you please post a workable sample data (not an image), your expected result from that and the reasoning behind. https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447... 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.