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
DominicHill
Frequent Visitor

Dax

Hi Folks, Please be gentle! I have been using DAX for a couple of months, and have managed quite well so far.

 

The problem is have is:

 

The powerpivot data looks like this. I have stripped out columns you don't need to see

 

Portcheck2Route BuilderUlitmate Trade RouteTrade 2Num_of_callsPort_call_numberCheck Col
NewP Indian Sub Cont & Middle East to Far East 815220
Ignore   825221
NewRIndian Sub Cont & Middle East to Sub Saharan Africa via Sub Saharan Africa835222
ignore   845223
newrIndian Sub Cont & Middle East to Indian Sub Cont & Middle East via Indian Sub Cont & Middle East855224
NewRIndian Sub Cont & Middle East to Far East via Far East865225
ignore   875226
VoyEnd   885227

 

 

What I want to achieve is where Portcheck2 is equal to "VoyEnd", then I 'join' the 'Ultimate Trade Route' with the items in Trade 2. - so I end up with 'Indian Sub Cont & Middle East to Far East via Sub Saharan Africa and via Indian Sub Cont & Middle East'. 

 

The Check Col are unique_ID's - I have just copied them, and I can reference them with the port_call_number and number of calls.  For the life of me I can't figure out how to do this!  I know that you 'don't do loops' in BI,  but this strikes me as the only way of doing.    

 

In longhand I am thinking

 

If the PortCheck2 column is equal to "VoyEnd", then take the value of the ultimate trade route where the data started (Lookupvalue of the Ulitmate Trade route at Col Check, Col Check-[Port_call_number]+1), and then join all non blank rows of Trade 2 between the start of Check Col, and the End of check col.   The Check Col boundaries are calculated using port_call_number.

 

Of course, this may not be possible, in which case I need to find another way!

 

Hope someone can help me!

3 REPLIES 3
BhaveshPatel
Community Champion
Community Champion

Hi @DominicHill

 

This seems really confusing. 

 

The specifications does not seem to be quite clear. From my initial understanding the scenario is more applicable to Power Query than DAX logic. 

 

Please provide more clear explanations.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Hi,  I can try and make it clearer.

 

The last column (check col) contains a unique reference number, for the start and end of the data needs to be looked at.

 

Between these two rows  (i.e. in Check Col, there is 5220 through 5227).

 

Starting row with reference 5220, Ultimate Trade route contains 'Indian Sub Cont & Middle East to Far East'.

5221 is blank, so can be ignored

5222 trade 2 column has 'via Sub Saharan Africa'

5223 is blank, therefore ignored

5224 trade 2 column has 'via Indian Sub Cont & Middle East'

5225 trade 2 column has 'via Far East'

5226 is blank

5227 is blank, but PortCheck2 contains 'VoyEnd', so I need to join the contents of 'Ultimate Trade Route'' (at 5220) to the contents of colum Trade 2 (at 5222 and 5224 and 5225 and 5227), but only for the rows between 5220 and 5227.  The next set of rows will start the process again.

 

If the final result needs to be in a different column, that's fine.

 

This is being done using Dax in a powerpivot worksheet, and the results will be used as a filter in a Pivot table.

 

If this is more suitable to an SQL query, then I can look a that, but it will set me back!  (Not that I am making any headway at the moment).

 

Thanks,

 

Dom

Hi @DominicHill ,

Could you please post your sample file to have a test and post your desired result if possible?

 

Regards,
Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.