Forum Discussion
Dynamic Measure based on slicer selection
Hi everyone,
I have a table which has a column, let's say called "Comments". I have created a slicer that lists all the comments and the user can select only the comments that they want. Based on the selection, the selected comments are shown in a Table. What I want to do is to show another column in the Table that will include 1,2,3 etc. For example, if the user selects to show 4 comments I want to show 1 on the left of the 1st comment, 2 on left of the 2nd comment and so on.
Any ideas?
Thanks
- Anonymous1 year ago
Hi Aria89 ,
Based on your description, I created this data.
Create the measure as SamWiseOwl said.Measure = RANK(SKIP,ALLSELECTED('Table'),ORDERBY('Table'[Comment]))
Successfully returned the expected result, you can refer to the attachment I provided to compare with your file. If possible, you can also provide your data (with sensitive data removed) so that we can better help you solve the problem.If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
9 Replies
- bhanu_gautamSuper User
Aria89 , Basically you are trying to add index in table then try below method
Create an Index Column: You need to create an index column that will generate the sequence numbers (1, 2, 3, etc.) for the selected comments.
Add a Custom Column in Power Query:
Go to the "Transform Data" option to open Power Query Editor.
Select your table.
Add a new custom column by clicking on "Add Column" > "Custom Column".
Use the following formula to create an index column:
= Table.AddIndexColumn(#"PreviousStepName", "Index", 1, 1, Int64.Type)
Replace #"PreviousStepName" with the name of the previous step in your query.Apply Changes: Click "Close & Apply" to apply the changes and return to the Power BI report view.
Use the Index Column in Your Table Visualization:
Add the new index column to your table visualization.
Ensure that the slicer is set up to filter the comments as required.- Aria89Helper I
Thanks for your response.
The thing is that if I just add an index column, the number associated with each comment is not going to change dynamically. I want the numbers shown in my table visual to always be 1,2,3,4 etc no matter what comments have been selected in the slicer.
- bhanu_gautamSuper User
Ok got it than you can use RANK function as stated by SamWiseOwl to create a measure and use it
- SamWiseOwlSuper User
Hi Aria89
Create a measure that ranks by the order your comments are in.
I assume its alphabetical so something like this:Rank comments Measure =RANK(SKIP,ALLSELECTED(CommentsTable),ORDERBY(CommentsTable[Comments]))- Aria89Helper I
Thanks for the response. I created that measure but when i add it in the visual, all the values are disappeared... Any ideas what can be wrong?
- SamWiseOwlSuper User
What else is in the table visual?
Are you applying any filters to the visual?
The row would dissapear if the measure is returning blank.
- AnonymousNot applicable
Hi Aria89 ,
Based on your description, I created this data.
Create the measure as SamWiseOwl said.Measure = RANK(SKIP,ALLSELECTED('Table'),ORDERBY('Table'[Comment]))
Successfully returned the expected result, you can refer to the attachment I provided to compare with your file. If possible, you can also provide your data (with sensitive data removed) so that we can better help you solve the problem.If your Current Period does not refer to this, please clarify in a follow-up reply.
Best Regards,
Clara Gong
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.