I'm new in DAX and PowerBI, just run into a "simple" problem, hope someone give me a hint.
The problem is like this: we have a data table behind a PowerBI report, its column "A" is of interest, and the report has several slicers work on that table.
The target is:
1. Firstly, to create an one-column dynamic table that contains the unique values of the sliced subset of the column "A" of the data table. After each time user makes his selection on the slicers, the table is automatically updated to refelct the new subsetting of the column "A".
2. secondly, to add a column to this dynamic table that contains the sequential numbers of the rows, i.e. 1, 2,..., N, with N the total number of rows.
Solved! Go to Solution.
Attached sample file considering the brand column as an example. It should work on any column and any set of slicers.
You need to place the column in a table visual along with the following measure
No. = RANKX ( CALCULATETABLE ( VALUES ( 'Product'[Brand] ), ALLSELECTED ( ) ), CALCULATE ( MAX ( 'Product'[Brand] ) ),, ASC, Dense )
Hi @tamerj1 , thank you for the reply. Your images looks the very thing I want, but
the code is generating a number rather than a table, maybe you missed to post another section of code?
Hi @Cheetah ,
In order to better understand your demands and give the right solution, could you please provide some more specific information? such as your desensitized example data and a screenshot of your desired results?
Thanks for your efforts & time in advance.
Community Support Team_ Binbin Yu
Hi @v-binbinyu-msft , thank you for the advice, and sorry for the missing informations. I got the problem solved. Thank you all as a great Community Support Team!
@Cheetah Not sure I 100% understand, but try this:
Measure = VAR __Values = DISTINCT('Table'[A]) // whatever the user selects for A column, unique values VAR __Text = CONCATENATEX(__Values,[A],"|") VAR __Count = COUNTROWS(__Values) VAR __Table = ADDCOLUMNS( GENERATESERIES(1,__Count,1), "A",PATHITEM(__Text,[Value]) ) // do something with this dynamic table. You now have a dynamic indexed table where the index is the [Value] column and your A values are in the A column.
HI @Greg_Deckler , thank you for the reply. I tried the code, it gives this error message: "The syntax for ')' is incorrect."
Should I add a "return" line to the end of the code?
@Cheetah Yeah, I have no idea what you want to do with that table VAR so that is just a code snippet, not a complete measure.
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.
130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.