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
lherbert501
Helper V
Helper V

Dax Logic

Hi,

 

Could somebody please help me with some Dax?

 

Location 1 and Location 2 are theorietically the same thing but are in my system twice and I need to say, if the qty column is greater than 0 and it matches on the item,loaddate and country, then the location 1 has to take priority and to ignore the item on location 2 but specifically only if it it a match and exists on location 1. There can be occasions where location 2 will have a qty and location 1 wont, but location 1 always has priority.

 

lherbert501_0-1697799869531.png

 

 

 

1 ACCEPTED SOLUTION

Hi @lherbert501 

You can refer to the following solution.

The sample data is the same as yours

1.Create a rank column

Rank =
RANKX (
    FILTER (
        'Table',
        [Item] = EARLIER ( 'Table'[Item] )
            && [Date] = EARLIER ( 'Table'[Date] )
            && [Country] = EARLIER ( 'Table'[Country] )
    ),
    [Location],
    ,
    ASC
)

2.Create a result column

Result = IF([Rank]=1,[Qty]) 

Output

vxinruzhumsft_0-1698126811239.png

 

Best Regards!

Yolo Zhu

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

 

View solution in original post

6 REPLIES 6
Ahmedx
Super User
Super User

look carefully, this is what you are looking for

Screenshot_3.png

@Ahmedx  Thanks for your reply.

 

Could you please explain a bit more?

 

Thanks

should I explain it or should you
I just wanted to reproduce your logic if I understood correctly
added a new column and there should be the word priority

I need something like 

 

If Location =' Location 1' and item,date and country match to location 2's  (so it already exists for the other location) then take quantity from location 1, else location 2. 

 

 

Hi @lherbert501 

You can refer to the following solution.

The sample data is the same as yours

1.Create a rank column

Rank =
RANKX (
    FILTER (
        'Table',
        [Item] = EARLIER ( 'Table'[Item] )
            && [Date] = EARLIER ( 'Table'[Date] )
            && [Country] = EARLIER ( 'Table'[Country] )
    ),
    [Location],
    ,
    ASC
)

2.Create a result column

Result = IF([Rank]=1,[Qty]) 

Output

vxinruzhumsft_0-1698126811239.png

 

Best Regards!

Yolo Zhu

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

 

Thankyou @v-xinruzhu-msft 

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.