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
amuola
Helper II
Helper II

Checking values in different rows

Hi,

 

I would like to set up a function that will check whether the same date appears for each of the order numbers in the below table.

Order nrOrder lineReceived dateDesired Output
230047448230047448-119.10.2017False
230047448230047448-225.10.2017False
230047450230047450-113.10.2017True
230047450230047450-213.10.2018True
230047453230047453-118.10.2017True
230047454230047454-118.10.2017True
230047459230047459-117.10.2017True
230047459230047459-217.10.2017True
230047461230047461-124.10.2017False
230047461230047461-224.10.2017False
230047461230047461-324.10.2017False
230047461230047461-430.10.2017False

For example, order number 230047448 has two order lines, received on the 19th and the 25th of October – desired output is “False”. The next order has the same received date on each of the order lines, hence desired output is “True”. If there is only one order line, it should return "True".

 

Appreciate any suggestions on this!

 

Amund

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @amuola

 

Try this calculated column

 

Desired Output =
VAR Total_Orders =
    CALCULATE (
        COUNTROWS ( TableName ),
        ALLEXCEPT ( TableName, TableName[Order nr] )
    )
VAR SameDate_Orders =
    CALCULATE (
        COUNTROWS ( TableName ),
        ALLEXCEPT ( TableName, TableName[Order nr], TableName[Received date] )
    )
RETURN
    IF ( Total_Orders = SameDate_Orders, TRUE (), FALSE () )

Regards
Zubair

Please try my custom visuals

View solution in original post

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

Hi @amuola

 

Try this calculated column

 

Desired Output =
VAR Total_Orders =
    CALCULATE (
        COUNTROWS ( TableName ),
        ALLEXCEPT ( TableName, TableName[Order nr] )
    )
VAR SameDate_Orders =
    CALCULATE (
        COUNTROWS ( TableName ),
        ALLEXCEPT ( TableName, TableName[Order nr], TableName[Received date] )
    )
RETURN
    IF ( Total_Orders = SameDate_Orders, TRUE (), FALSE () )

Regards
Zubair

Please try my custom visuals

yes, it works, thank you so much! Could you please explain the formula and why this is working?

 

Regards Amund

Hi @amuola

 

Here is how it works

 

1) ALLEXCEPT ( TableName, TableName[Order nr] )

filters your table and returns the rows with the same Order Number as Current Row

 

2) ALLEXCEPT ( TableName, TableName[Order nr], TableName[Received date] )

filters your table and returns the rows with the same Order Number and same date as Current Row

 

You can try these in separate columns for learning

 

Total_Orders =
    CALCULATE (
        COUNTROWS ( TableName ),
        ALLEXCEPT ( TableName, TableName[Order nr] )
    )
SameDate_Orders =
    CALCULATE (
        COUNTROWS ( TableName ),
        ALLEXCEPT ( TableName, TableName[Order nr], TableName[Received date] )
    )

Regards
Zubair

Please try my custom visuals

excellent! Again, thank you so much.

 

Regards

Amund

@amuola

 

110.png


Regards
Zubair

Please try my custom visuals

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.