Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

INDEX for table with DAX

Hello ,

   I want to create index wiht DAX for following table. But I could not create a column  because working in Direct Query. That why I need a different solution.
   The index that will be created with DAX must be ranked with Quanty and sales prices. Sales price and Quantity are directly proportional; when one of them increases other one also increases.

 

                                                        

The outout of DAXThe outout of DAX

Power BI VısualPower BI Vısual

7 REPLIES 7
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use the following measure to get an index.

 

index = 
IF (
    HASONEVALUE ( 'Table'[CHAN] ), 
    RANKX ( ALLSELECTED ( 'Table'[CHAN], 'Table'[QUANTY] ), [SALES PRICE] )
)

 

The result like this,

 

index 1.jpg

 

Best regards,

 

Community Support Team _ zhenbw

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

Anonymous
Not applicable

Hi @v-zhenbw-msft ,

  Could yo share pbix with me?
  It seems like to work but in my desktop does not works, although I checked my code a lot.

 

Thanks, Br

Greg_Deckler
Super User
Super User

Not exactly sure I get it. But, maybe check out 

 
To *Bleep* with RANKX!


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User
parry2k
Super User
Super User

@Anonymous so what exactly you are after, an Index column? How you are planning to use it? I guess sales price is a measure?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Yes,Sales price is measure. I want to add index column for power bi visual on above.
az38
Community Champion
Community Champion

Hi @Anonymous 

according the radacad RANKX bible from @amitchandak link, you can try to create a measure like

	RANKX(
		ALL('Table') ,
		CALCULATE(
			SUM('Table'[Sales Price])
			)
	)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.