Sorting discrepancy

In powerbi
I have a table which has cols–articlecode, MRINDate, netprice , masternetprice.
I have sorted the table on articlecode( ascending) and MRINDate ascending , as 1 articlecode can have 1 or more MRINdateusing powerquery

Its sorted , but when i use this table in visulization, MRINDate is not coming in sorted order
I have to create price history
Sorted data in table looks like this
Articlecode netprice mrindate
1-10-11 23.00 21 jan 2022
1-10-12 24.00 21 jan 2022
1-10-12 24.00 3 feb 2022
1-10-12 23.00 4mach2022
1-10-12 26.00 6mrch2022
1-10-13 0.23 21jan2022

But in visulization its coming
1-10-11 23.00 21 jan 2022
1-10-12 24.00 3feb2022
1-10-12 24.00 21jan2022
1-10-12 23.00 6mach2022
1-10-12 26.00 4mrch2022
1-10-13 0.23 21jan2022

Hi @RachnaJain ,

it’s hard to tell without pbix sample file,

but check the model and joins.

Good luck.

I am having other issues too, i will connect with details.

[quote=“RachnaJain, post:1, topic:48329, full:true”]
In powerbi
I have a table which has cols–articlecode, MRINDate, netprice , masternetprice.
I have sorted the table on articlecode( ascending) and MRINDate ascending , as 1 articlecode can have 1 or more MRINdateusing powerquery

Its sorted , but when i use this table in visulization, MRINDate is not coming in sorted order
I have to create price history
Sorted data in table looks like this
Articlecode netprice mrindate
1-10-11 23.00 21 jan 2022
1-10-12 24.00 21 jan 2022
1-10-12 24.00 3 feb 2022
1-10-12 23.00 4mach2022
1-10-12 26.00 6mrch2022
1-10-13 0.23 21jan2022

But in visulization its coming
1-10-11 23.00 21 jan 2022
1-10-12 24.00 3feb2022
1-10-12 24.00 21jan2022
1-10-12 23.00 6mach2022
1-10-12 26.00 4mrch2022
1-10-13 0.23 21jan2022

Another issue to be solved in the following table
I am having other issues too, i will connect with details.

[quote=“RachnaJain, post:1, topic:48329, full:true”]
In powerbi
I have a table which has cols–articlecode, MRINDate, netprice , masternetprice.
I have sorted the table on articlecode( ascending) and MRINDate ascending , as 1 articlecode can have 1 or more MRINdateusing powerquery

Its sorted , but when i use this table in visulization, MRINDate is not coming in sorted order
I have to create price history
Sorted data in table looks like this
Articlecode netprice mrindate masterunpr
1-10-11 23.00 21 jan 2022 24
1-10-12 24.00 21 jan 2022 12
1-10-12 24.00 3 feb 2022 11
1-10-12 23.00 4mach2022 12
1-10-12 26.00 6mrch2022 24
1-10-13 0.23 21jan2022 .24

For thistable sorted by articlecode and podate i want 3 more columns

Prevnetprice, pricechange and podateofchange

Where

  1. if 1 row for articlecode
    Prevnetprice=
    Masterunprice
    And if more rows
    Then prevnetprice = netprice- ( value of netprice in previous row)
  2. if there is price change then
    Podateofchange= currentpodate
    Pricechange= either+or- and the value difference

I am unable to store prevnetprice when multiple rows of an articlecode
I have tried dax

VAR CurrentArticleCode = [ArticleCode]
VAR CurrentMRINDate = [MRINDate]

VAR PreviousRow =
CALCULATETABLE(
FILTER(
ALL(SortedTable),
SortedTable[ArticleCode] = CurrentArticleCode
&& SortedTable[MRINDate] < CurrentMRINDate
),
TOPN(1, SortedTable, SortedTable[MRINDate], DESC)
)

VAR NetPriceAtPreviousMRINDate =
IF(
NOT ISEMPTY(PreviousRow),
PreviousRow[NetPrice],
[MasterUnitPrice] – Only one row for ArticleCode
)

RETURN
NetPriceAtPreviousMRINDate

VAR CurrentArticleCode = [ArticleCode]
VAR CurrentMRINDate = [MRINDate]
VAR PreviousRow =
CALCULATETABLE(
FILTER(
ALL(SortedTable),
SortedTable[ArticleCode] = CurrentArticleCode
&& SortedTable[MRINDate] < CurrentMRINDate
)
)
VAR NetPriceAtPreviousMRINDate =
IF(
NOT ISEMPTY(PreviousRow),
EARLIER(PreviousRow[NetPrice]),
[MasterUnitPrice] – Only one row for ArticleCode
)
RETURN
NetPriceAtPreviousMRINDate

Mrindate is podate

without seeing your power bi file, its hard to tell what is the problem

Thanks , sorting problem is solved. For another query do i have to open another topic or i can rewuest here.
Thanks to both again

yes you have to open a new topic. One subject per posting is the rule as if others in the forum is looking for a certain problem. They won’t be confused by the subject.

If you solved the problem it would great if you can post the solution so others can learn. if the problem is solved then marked as solved for the person who solved. Please don’t leave the posting open.

There are guideline for the forum

thanks
Keith

Thanks, my calculations were making some sorting disorder. I removed some Dax and the problem was solved. I will open another thread, need further assistance.
I am new to power bi and have started working after a gap of nearly 15 years, so kindly point my mistakes.
Thanks again

how to close this thread please?

Hi @RachnaJain,

Please see the the following link on how to solve/close the thread.
How To Use The Enterprise DNA Support Forum - Forum Guides - Enterprise DNA Forum

thanks
Keith

thanks a lot, hope i have closed “sorting discrepancy” properly. still looking forward to the solution to values in IndexCol

Hi @RachnaJain ,

Could you open new thread (as @Keith mentioned) for IndexCol
Explaining that part

maybe to provide pbix sample file
or at least part of model & measure & some part of context where might be the problem.

More information you provide, easier and quicker other members could help.

Thanks.

Best regrads,
Maja

sorry, created new topic

1 Like