cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper II

## Rownumber in virtual table

Hi All,

I have created a virtual table using the below DAX function. I want to create a rownumber column based on the

partition by YEAR, REGION, PRODUCT and Order by SALES (Could be strange for you) within the virtual table.

SUMMARIZECOLUMNS(
'Data'[YEAR],
'Data'[REGION],
'Data'[PRODUCT],
'Data'[SALES],
'Data'[PERIOD]
)

1 ACCEPTED SOLUTION
Community Support

Hi, @vinothkumar1990
Based on your information, I create a table:

You can create a new measure and try the following DAX:

``````Vitrue Rank =
VAR VirtualTable =
SUMMARIZE(ALLSELECTED(Data),
'Data'[YEAR],
'Data'[REGION],
'Data'[PRODUCT],
'Data'[SALES],
'Data'[PERIOD]
)

VAR ResultTable =
VirtualTable,
"RowNumber",
RANKX(
VirtualTable,
'Data'[SALES],
,
DESC,
Dense
)
)

RETURN
MAXX(FILTER(ResultTable,SUM(Data[SALES])=[SALES]),[RowNumber])
``````

Here is my preview:

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 REPLIES 3
Community Support

Hi, @vinothkumar1990
Based on your information, I create a table:

You can create a new measure and try the following DAX:

``````Vitrue Rank =
VAR VirtualTable =
SUMMARIZE(ALLSELECTED(Data),
'Data'[YEAR],
'Data'[REGION],
'Data'[PRODUCT],
'Data'[SALES],
'Data'[PERIOD]
)

VAR ResultTable =
VirtualTable,
"RowNumber",
RANKX(
VirtualTable,
'Data'[SALES],
,
DESC,
Dense
)
)

RETURN
MAXX(FILTER(ResultTable,SUM(Data[SALES])=[SALES]),[RowNumber])
``````

Here is my preview:

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helper II

@v-yohua-msft - Thanks for your help!

Is there any possiblity to use the Rownumber function?

Community Support

Yes, you can use Rownumber function, here is the DAX expression:

``````Vitrue Rownumber =
VAR VirtualTable =
SUMMARIZE(ALLSELECTED(Data),
'Data'[YEAR],
'Data'[REGION],
'Data'[PRODUCT],
'Data'[SALES],
'Data'[PERIOD]
)

VAR ResultTable =
VirtualTable,
"RowNumber",
ROWNUMBER(
ORDERBY([SALES],
DESC)
)
)

RETURN
MAXX(FILTER(ResultTable,SUM(Data[SALES])=[SALES]),[RowNumber])
``````

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors