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
sunah132
Helper I
Helper I

Rank and Partition

I have a list of items with pricing as value by delivery date. Because the direct query data has multiple duplicated entries per items, the row subtotal shows 10X more than what it should be. If I create a new measure with rank to bring most recent data shown to make the subtotal, what should it be? Thank you in advance.

 

This is what I thought to use rankx 

Rank =

RANKX(ALL(Hub,Item),Item Cost)

 

sunah132_1-1623397869479.png

 

 

11 REPLIES 11
v-yetao1-msft
Community Support
Community Support

Hi @sunah132 

I took a look at the pbix file you provided, and the current rendering is as follows. What is the result you need, could you explain it? From the data you provide so far, I am not particularly clear about your needs.

Ailsa-msft_0-1623749170667.png

Best Regards

Community Support Team _ Ailsa Tao

 

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

Hi Ailsa,

There are multiple duplicated data per item and I had to bring the minimum cost of the table per day to sum up the total. There were daily pricing and misc. pricing on every Wednesday that I had to put together into the table with minimums on it. I tried tweaking Ryan's DAX to both charges added onto it but I was struggling getting them calculated. Thank you for look into this!

sunah132_0-1623823312926.png

 

amitchandak
Super User
Super User

@sunah132 ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

You can get last price for an item like

 


Measure =
VAR __id = MAX ('Table'[item] )
VAR __date = CALCULATE ( MAX('Table'[Date] ), ALLSELECTED ('Table' ), 'Table'[item] = __id )
CALCULATE ( max ('Table'[price] ), VALUES ('Table'[item] ),'Table'[item] = __id,'Table'[Date] = __date )

 

@sunah132 

you can try this

Measure 2 = 
var TBL=SUMMARIZE('Sheet1',Sheet1[Date],Sheet1[Item],Sheet1[Item code],"min",min(Sheet1[Item Cost]))
RETURN SUMX(TBL,[min])

  please see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you!! It applied as I was expected! 

If there's a miscellaneous cost on every Wednesday per item code, may I add like this?

https://app.powerbi.com/links/XlboCMDYjw?ctid=da67ef1b-ca59-4db2-9a8c-aa8d94617a16&pbi_source=linkSh... 

 

var TBL=SUMMARIZE('Sheet1',Sheet1[Date],Sheet1[Item],Sheet1[Item code],"min",min(Sheet1[Item Cost],(sheet1[Misc cost]))
RETURN SUMX(TBL,[min])

 

 

 

@sunah132 

I can't access to the link you shared. could you pls share via dropbox?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Yes, Sorry. Here is the dropbox link below.

https://www.dropbox.com/s/2ead8gbkb7tzrlx/P1.pbix?dl=0 

@sunah132 

I can download your pbix file. what's the expected output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hello,

As the table below, I tried to see if I can add the MIN of Misc charge add up with the item cost if they were on the same delivery date. Thank you very much!

sunah132_0-1623638455382.png

 

@sunah132 

you can try this

Measure =
var TBL=SUMMARIZE('Sheet1',Sheet1[Date],Sheet1[Item],Sheet1[Item code],"min",min(Sheet1[Item Cost])+min(Sheet1[Misc Cost]))
RETURN SUMX(TBL,[min])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.