Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
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.
Thank you!
Cheetah
Solved! Go to Solution.
@Cheetah
Indeed it is generating a number. Which you need to place it along with the desired column in one table visual. Please download the attached file and see how it works.
Hi @Cheetah
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?
Cheetah
@Cheetah
Indeed it is generating a number. Which you need to place it along with the desired column in one table visual. Please download the attached file and see how it works.
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.
Best regards,
Community Support Team_ Binbin Yu
Hi @Anonymous , 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.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
21 | |
20 | |
19 | |
13 | |
12 |
User | Count |
---|---|
42 | |
28 | |
23 | |
22 | |
22 |