Forum Discussion
Rank In PBI
Hi , Anonymous
Thanks for your quick response!According to your description, you want to show the last1 content title , if this , you can replace the DESC to ASC to check if it can meet your need.
Measure 2 = MAXX( TOPN(1, ADDCOLUMNS( CALCULATETABLE( SUMMARIZE('Dim Content','Dim Content'[ID],'Dim Content'[Content tiltle]) , ALLEXCEPT('Dim Content','Dim Content'[News Type]) ) , "Views" , CALCULATE(SUM('Fact User'[Views]))) ,[Views] ,ASC) , [Content tiltle])
The MAXX() in this dax code just get the text in the table got from TOPN() function.So when you replace the MAXX() to MINX() , it will show the same in your visual.
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
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
Hi,
Thanks a lot for replying, actually for top views and bottom views it showing same views count...
Can you please help me on resolving this issue
- Anonymous3 years agoNot applicable
Hi,
ContentId date published_at metadata user_id id Sum of nb_content_views Sum of nb_content_likes Sum of nb_content_comments content_title content_type_name Filtered News Type 54020412 6/28/2023 0:00 5/12/2023 17:59 Video 45037090 df826ded7681bae5d15e18b56ac242e8 1 0 0 We invited mothers for an unforgettable experience News Regional News 59300990 6/1/2023 0:00 5/19/2023 21:22 Training 45037031 6ef863e1d58ac36e4af26ccab7afe429 1 0 0 2023/06/07: Masterclass: Working Effectively Across Cultures Events 59300990 6/1/2023 0:00 5/19/2023 21:22 Training 45037031 79ba432f759c4b0b7585ba40b395c589 1 0 0 2023/06/07: Masterclass: Working Effectively Across Cultures Events 59300991 6/2/2023 0:00 5/19/2023 21:22 Training 45037090 baec93e847a9ce0b6120c7ec752a6900 1 0 0 2023/06/07: Masterclass: Working Effectively Across Cultures Events 45317681 6/15/2023 0:00 5/31/2023 22:00 Engagement 45037031 867d3eca5c6269c5aa8b0c93cb695f90 1 0 0 News 45317681 6/15/2023 0:00 5/31/2023 22:00 Engagement 45037031 ce5d58aeeb337248c65cd492111453b3 1 0 0 News 49851883 6/3/2023 0:00 5/31/2023 22:00 Scholarships 45037031 3aa91a5dced42d77103930d97782f972 1 0 0 Deadline: June 15 - 2023 Student Awards Reminders 49851883 6/3/2023 0:00 5/31/2023 22:00 Scholarships 45037031 98d6acfcc69c0c706e1eb1971a1beecf 1 0 0 Deadline: June 15 - 2023 Student Awards Reminders 55549280 6/15/2023 0:00 6/5/2023 22:00 Wellness 45037031 83d584a5ac9132f424c907fc93d4acad 1 0 0 News 55549280 6/15/2023 0:00 6/5/2023 22:00 Wellness 45037031 8f463c95c5c415f43d4e0bcfab9f5ab6 1 0 0 News 46539003 6/27/2023 0:00 6/15/2023 21:47 Purpose and Values 45037031 baf4cd9dfa35724b07046b52c1e8d28b 1 0 0 2023/06/27: Join our Masterclass Events 46539003 6/27/2023 0:00 6/15/2023 21:47 Purpose and Values 45037031 d5014526c27083e592727bf8a1cf062f 1 0 0 2023/06/27: Join our Masterclass Events 57337827 6/27/2023 0:00 6/21/2023 22:00 Benefits 45037031 5c6cd758468b2f317e0cf77fff99db1d 1 0 0 News 57337827 6/27/2023 0:00 6/21/2023 22:00 Benefits 45037031 73b2da007de296674bc8bdc20b5c4d3c 1 0 0 News 52336239 6/30/2023 0:00 6/25/2023 22:00 Welcome 45037090 db8f4d5b62b7635acf6a2906a04af38e 1 0 0 New Iconic Emblem News Global News 52594039 6/28/2023 0:00 6/27/2023 14:28 Welcome 45037090 ed801576fd2f050817bc29cf481c5022 1 0 0 Your Way: ‘Easy to Always Be Charged’ News Global News 61743063 6/5/2023 0:00 7/4/2023 7:00 Programs 45037031 9c3c05873d4f44899ea003afbcd835a5 1 0 0 News TThis si the sample data
For one date there are many published at dates - v-yueyunzh-msft3 years agoCommunity Support
Hi, Anonymous
Thanks for your quick response!
I test it in my sample pbix file , it seems work .
You can check my pbix file and if we may have some difference in relationships?
Or maybe I've misunderstood your needs too?
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
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
- Anonymous3 years agoNot applicable
Hi,
Thank you so much for replying
It helped
I am trying to show views for that comtent title also, butr what the issue i am facing here is instead of showing the view number for that particular content for a particular news type, it's showing summation of whole news type and showing for a content type
For example:
For Global News Highets viewed content title is GT News1 it must show views number only for that content title
But it's showing summation of whole views for that Globe News News type and same for local news and region news
actually views column is summarized column
Please help me
Thanks in advance - v-yueyunzh-msft3 years agoCommunity Support
Hi , Anonymous
Thanks for your quick response !
According to your description, you want to show views.
I create two measures you can check if it can meet your need:
Value Per News Type = CALCULATE( SUM('Fact User'[Views]) , ALLEXCEPT('Dim Content','Dim Content'[News Type]))Max Value = CALCULATE( SUM('Fact User'[Views]) , TREATAS({[Max Value of Content title]} , 'Dim Content'[Content tiltle]) , ALLEXCEPT('Dim Content','Dim Content'[News Type]) )We can test it in the visual , the reuslt is as follows:
If this still does not meet your needs, you can provide me with the final results you want in a form based on my test data.
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
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
- Anonymous3 years agoNot applicable
Hey Hi,
Thanks alot for replying to all the help
I will place the example data from excel here
Here I just want to see content title which are having highest views
For each news type I want to see content title which are having highest viewsNews Type Content Title Views Global team to lead Company through increasingly challenging external environment 11,900 Region Competitors are coming 4,596 Region Team at exhibition 3,794 Global New Iconic 3538 Loaclity Solution for disabilities 1,596
For Global, Region and Locality I want to see only top view content title
And I just have only one table that is Fact tavle no other tables are there
can you please help??
Thanks in advance - v-yueyunzh-msft3 years agoCommunity Support
HI , Anonymous
Thanks for your quick response!
According to your description, you only have one table and you want to show the highest content title. This is my understand and test data for your need:
If this , we canc reate a measure like this:
Measure = var _cur_type= MAX('Table'[News Type]) var _t =CALCULATETABLE( SUMMARIZE('Table','Table'[News Type],'Table'[Content Title],"views" , SUM('Table'[Views])) , ALLEXCEPT('Table','Table'[News Type])) return IF( MAXX(topn(1,_t,[views],DESC) , [Content Title]) = MAX('Table'[Content Title]) , 1, -1)Then we can put this measrue on the "Filter on this visual":
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
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
- Anonymous3 years agoNot applicable
Hi,
Thanks for replying...
This is not working
can we do it with rank function if possible? - v-yueyunzh-msft3 years agoCommunity Support
Hi , Anonymous
Thanks for your quick response! Soorry for that this dax code can not work in your side . Did you not put [News Type] as dimension in your visual so that the dax code will not work.
If you just put the [Content Title] in the visual , you can use this dax code:
Measure 2 = var _cur_type= MAX('Table'[News Type]) var _t =CALCULATETABLE( SUMMARIZE(ALLSELECTED('Table'),'Table'[News Type],'Table'[Content Title],"views" ,CALCULATE( SUM('Table'[Views]))) ) var _t2 = FILTER(_t, [News Type] = _cur_type) return IF( MAXX(topn(1,_t2,[views],DESC) , [Content Title]) = MAX('Table'[Content Title]) , 1, -1)Since placing different fields will result in different filtering contexts, if this DAX code still cannot meet your needs, you can provide me with the fields you need to place and your final results in a table form.
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
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
- Anonymous3 years agoNot applicable
Hi,
I am adding News type as dimension only.
I am adding content title, News type, Views, Published date, created by name
I am filtering it by date
For example If i select between 1st june 2023 to 30th june 2023 it must show only one top view content title for each news
and there is many published dates for one date
For example for 1st june 2023 there are many published dates
Here view is , content title viewd by user on that date
Published date is date when the content is published
all this columns i am adding
Please reply
Thanks - v-yueyunzh-msft3 years agoCommunity Support
Hi , Anonymous
Thanks for your quick response! According to your description, this is my understand:
If this is the same as yours table structure and the end result is right, you can refer to :
(1)We can create two measures:MAX views = var _t = SUMMARIZE('Table','Table'[Content Title],"value", SUM('Table'[Views])) var _t2 = TOPN(1,_t , [value] , DESC ) return SUMX(_t2 , [value])MAX COntent Title = var _t = SUMMARIZE('Table','Table'[Content Title],"value", SUM('Table'[Views])) var _t2 = TOPN(1,_t , [value] , DESC ) return maxx(_t2,[Content Title])(2)Then we can put it on the visual and just put the [News type] as the dimension only!
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
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
- Anonymous3 years agoNot applicable
Hi Aniya zhang,
Thanks for being patient and replying to my problemNews Type Content Title Views Global team to lead Company through increasingly challenging external environment 11,900 Region Competitors are coming 4,596 Region Team at exhibition 3,794
I just need to show this
only one top content title and it's respective view for each news type
but when i am adding created by name, published date dimension columns into the table
it's showing many values
I'll paste the dax i have used below
Top View = IF ( ISINSCOPE( 'Fact Content'[content_title] ), RANKX ( CALCULATETABLE ( VALUES ( 'Fact Content'[content_title] ), ALLSELECTED( ( 'Fact Content'[content_title] ), 'Fact Content'[Filtered News Type]) ), 'Fact Content'[Month Filter] ) )Month Filter = CALCULATE(SUM('Fact Content'[nb_content_views]), MONTH('Fact Content'[date]) = MONTH(MAX('Fact Content'[date])) - 1)
the below is the output i am getting
But after adding created by name , published_at columns it's splitting down to many rows like below
Please helpp
It's very important for me
Thanks
sai - v-yueyunzh-msft3 years agoCommunity Support
Hi , Anonymous
Thanks for your quick response! According to your screenshot and your dax code . The [Month Filter] measure seems to calculate the views in the previous month . And the [Top View] is used to filter the highest views in your table visual and it work good in your screenshot . And the issue is that when you put the other field like [Created By Name] or the [Published Date] , the table visual will not work.
For this, i think this not the reason for your [Top view] measure. Due to your Views is the previous month so you can not just directly put the other fields to the visual.I also test it in my side , but i still have no sample data as the same as yours so I can't completely guarantee that my situation is exactly the same as yours.
This is my test data and my understand now:
For this i use your two measures you provided and it work good in my side .If you want to add the [Created By Name] or the [Published Date], you may need to create measures to realize it:
Created Name Measure = CALCULATE( MAX('Fact Content'[created by name]) , MONTH('Fact Content'[date]) = MONTH(MAX('Fact Content'[date])) - 1)
Published Date Measure = CALCULATE( MAX('Fact Content'[published_at]) , MONTH('Fact Content'[date]) = MONTH(MAX('Fact Content'[date])) - 1)
Then we can get the right value due to it is from previous month so we can not just directly put it on the visual.
If this method still can not help you solve this case , can you just share me some sample data as the same as yours in a table format , and your end result you need also.Inconsistencies in data structures can complicate things very much, and [Filtered News Type] also appears in your DAX, I'm not sure what the relationship is to [News Type]?Hope this solution can help you!
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
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
- Anonymous3 years agoNot applicable
Hi,
Thanks for replying,
when I am using the dax you have given the output is like belowIt's not showing name and dates for all news types, only for one....please reply
Filtered news type is created column based on one more column
I am taking everything from only one table that is Fact Content
I don't know, why nothing is working here, maybe group by works ....
Please help
Thankss in advance - v-yueyunzh-msft3 years agoCommunity Support
Hi, Anonymous
Thanks for your quick response ! And sory for that this dax code still can not work , it is very strange For this dax "Created Name Measure = CALCULATE( MAX('Fact Content'[created by name]) , MONTH('Fact Content'[date]) = MONTH(MAX('Fact Content'[date])) - 1)" :
This is just calculate the last montn "created by name" as the same logic as your [Month Filter] measure.And for the "Views" in your visual , in my undersand , this is just the [Month Filter] measure, right?
And only one situation for there is only one poosible is that the [created by name] and [published Date] is contains blank in your table?
And I'm not sure what you want to get the following [created by name] and [published Date], I used the same logic as your [Month Filter] in dax.So can you send me the download link of the sample .pbix (you can cr eate a test .pbix and make this isssue in it ,and also give me the end result !) you have the error problem with? Then tell me the data and calculation logic you need to display, which can make the problem simpler and clearer? 😁Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
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
😘 - v-yueyunzh-msft3 years agoCommunity Support
Hi , Anonymous
Thanks for the sample data very much!!! But where is the "News Type" in your visual and i can not find it in the sample data....
And dose this [Views] in your table is using your [Month Filter] measure?
And dose your actually need is to see the highest views in the previous month?And i see your sample data there is many blank value in the [Filtered News Type] and [Content Type]...
And i do not surely understand which you want to group by if used the [Filtered News Type] and [Content Type]?
I'm really sorry, I checked your sample data, but I'm still not very clear about your needs. . .And you want to get [Created by Name] and [Published Date], but is it possible for each [News type] and [Content Title] to have multiple [Created by Name] and [Published Date]? So which one do you want to get?If possible, can you tell me about your business logic and the final result you want?Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
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