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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
cz1750
Frequent Visitor

Validating excel source is in numerical order

Hi,

I was wondering if it's possible to check items loaded from a excel source to validate that they have been entered in numerical order as expected (1,2,3,4...)

I.e set flag to "Error" and coloured red if the following occurred in the excel source data, as listed below, where id 4 was entered before id 3

Id.
1
2
4
3


Thanks

J
1 ACCEPTED SOLUTION

Hi @cz1750,

 

Sorry for the delay.

 

Yes, if you got a sequence column, it will be better for the ordering. Please refer to following sample:

 

The source data in Excel is like:

3.PNG

 

After loading it into Power BI, it displays as:

Not the right sequenceNot the right sequence

 

Then you can use following calculated column to verify the previous value.

Previous Value =
CALCULATE (
    MAX ( Sheet1[id] ),
    FILTER (
        ALL ( Sheet1 ),
        Sheet1[Ordering]
            = EARLIER ( Sheet1[Ordering] ) - 1
            && Sheet1[Grouping] = EARLIER ( Sheet1[Grouping] )
    )
)

5.PNG

 

As you can see, even though the ordering is not right. The previous value is still returning the expected result.

 

Thanks,
Xi Jin.

View solution in original post

4 REPLIES 4
v-xjiin-msft
Solution Sage
Solution Sage

Hi @cz1750,

 

Why did you need to this?

 

Sometimes when load data from excel to Power BI. The source may be ordered by other columns like text strings or other columns. It doesn't mean this is wrong. We just can't define a default order for the source for now when loading data. And if you have a numerical column like Id, you can simply re-order the source based on this Id column. 

 

I don't think it is necessary to do the validation.

 

Thanks,
Xi Jin.

Hi,

 

Thanks for your reply

 

The reason I need to ensure that the ids are i n order is that there are wightings applied to item 1,2,3,4 etc - so if the ids arein in order it means they applied the wrong weighting to the item

 

 

i.e.

 

correct data where the ids are in the correct order and the relevant weighting is correct thats applied to it

 

id      weighting

1      <weighting 1st item>

2      <weighting 2nd item>

4      <weighting 3rd item>

7      <weighting 4th item >

 

 

But if an id is entered in te wrong order then the wrong weighting is being recorded/applied to it (for id 4 and 3 below - they will bother result in having the wrong weighting applied due to the bein entered in the wrong order)

 

id      weighting

1      <weighting 1st item>

4      <weighting 2nd item>

2      <weighting 3rd item>

7      <weighting 4th item >

 

 

Thanks

 

J

cz1750
Frequent Visitor

Hi,

 

 

To  mkae the ordering better i have added a copumn callled grouping to group associated valuse and a Ordering column to specify what was entered 1st, 2nd, 3rd and 4th

 

Grouping                id      Ordering     weighting

Group1                    1        1               <weighting 1st item>
Group1                    2        2               <weighting 2nd item>
Group1                    4        3               <weighting 3rd item>
Group1                    7        4               <weighting 4th item >

Group2                    1        1               <weighting 1st item>
Group2                    2        2               <weighting 2nd item>
Group2                    7        3               <weighting 3rd item>
Group2                  10       4                <weighting 4th item >

 

So the previous values would be set as follows

 


Grouping                id      Ordering     weighting                        Previous Value

Group1                    1        1               <weighting 1st item>      NULL
Group1                    2        2               <weighting 2nd item>    1
Group1                    4        3               <weighting 3rd item>     2
Group1                    7        4               <weighting 4th item >    4

Group2                    1        1               <weighting 1st item>     NULL
Group2                    2        2               <weighting 2nd item>    1
Group2                    7        3               <weighting 3rd item>     2
Group2                  10       4                <weighting 4th item >    7

 

 

Thanks

 

J

Hi @cz1750,

 

Sorry for the delay.

 

Yes, if you got a sequence column, it will be better for the ordering. Please refer to following sample:

 

The source data in Excel is like:

3.PNG

 

After loading it into Power BI, it displays as:

Not the right sequenceNot the right sequence

 

Then you can use following calculated column to verify the previous value.

Previous Value =
CALCULATE (
    MAX ( Sheet1[id] ),
    FILTER (
        ALL ( Sheet1 ),
        Sheet1[Ordering]
            = EARLIER ( Sheet1[Ordering] ) - 1
            && Sheet1[Grouping] = EARLIER ( Sheet1[Grouping] )
    )
)

5.PNG

 

As you can see, even though the ordering is not right. The previous value is still returning the expected result.

 

Thanks,
Xi Jin.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.