Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7654 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

what would be my first step in trying to sort portal rows? i would like to create buttons near the top of the columns that will sort each column in ascending and descending order. any help would be much appreciated. cheers!

Posted

The basic idea is that you set up a calculation in the related file to sort by. Let's say you have nID, tName, & dDate fields in your related file that you're showing in your portal. If you click a field header, you'll set a global field (gFlag, for example) in the related file. The calculation determines which field to sort your portal by based on the value of the global field. Your calculation would look like this:

Case(

gFlag="ID", nID,

gFlag="Name", tName,

gFlag="Date",dDate,

nID)

When you set the sort by field option in your relationship, you'll select the calcuation in the related file. If you don't select a field header, the poral will default to sorting by nID.

Is that enough to get started?

Posted

I've done it by creating multiple relationships, each sorted as required. Create identical layouts each with the differently sorted portal on it. The magic then consists of switching between the layouts.

A bit crude compared with John's sugestion. wink.gif

Posted

the forums had went down last week before i was able to post a "thank you" to you John. thank you very much for helping me out with this issue, much appreciated.

cheers!

  • 4 weeks later...
Posted

John,

I can't seem to get Numbers to sort properly, I'm pretty sure I know why, but I can't seem to resolve it. This is how it would sort numbers:

1,234,567

2,345

4,567,345

etc...

based on the first numeral.

Can you provide any insight?

Posted

It looks like the numbers are in a text field. You may have to have a calculation that puts leading zeros in front of your number if your sort by calc. returns a text value. In your example, your numbers would format like this:

1,234,567

0,002,345

4,567,345

That would cause them to sort properly:

0,002,345

1,234,567

4,567,345

This is because text is literal - the leading zeros must be considered when sorting, whereas they are truncated in a number field.

I don't have FileMaker here at work, so I can't check my sample file, but I think one of the tweaks I had to do was to put in leading zeros in my example. I'll have a look this evening.

Posted

The numbers in the portal don't have to display the leading zeros. The "sort by" calculation has to have the leading zeros. You can have a seperate text calculation that converts your non leading zeros (the ones that are displayed in the portal) into numbers with leading zeros and use that value in your sort by calc.

cool.gif

Posted

argh, for the life of me..........

so i am trying to get this to work, but i do now know where to convert the number into text in order for it to sort properly. Would it be in the "sortBy" field?

Case(

sortFlag="Trade",subcontractor,

sortFlag="ContractAmount", contractAmount,

subcontractor)

The thing I noticed is that if the Calculation Result is changed to "Number" then it works. Sorry for the ignorance John, I am an extra newbie.

Posted

No need to apologize!

I would create a separate calculation for this. Here is a relatively simple way to skin this cat. shocked.gif

Create this (number) calculation cLen: Length(Int(countractAmount))

This will tell you how many digits the whole dollar amount of your contractAmount is.

Let's say it's safe to assume that your max Contract Amount will never be more than $999,999,999 (maximum of 9 digits).

Create a text calculation called cContractAmt:

Case(

cLen=1, "00000000" & NumToText(contractAmount),

cLen=2, "0000000" & NumToText(contractAmount),

cLen=3, "000000" & NumToText(contractAmount),

cLen=4, "00000" & NumToText(contractAmount),

cLen=5, "0000" & NumToText(contractAmount),

cLen=6, "000" & NumToText(contractAmount),

cLen=7, "00" & NumToText(contractAmount),

cLen=8, "0" & NumToText(contractAmount),

NumToText(contractAmount))

This calc looks at the number of digits of the whole dollar amount in your contractAmount field and appends the number of leading zeros it needs based on the number of digits.

So now your flag calculation looks like this:

Case(

sortFlag="Trade",subcontractor,

sortFlag="ContractAmount", cContractAmt,

subcontractor)

My standard disclaimer: I don't have FM at work, so this hasn't been tested. And there are certainly more complicated ways of determining the max digits (using a self join relationship for example), but this will work unless you anticipate having huge contracts.

Good luck!

cool.gif

Posted

Is that a trick question? wink.gif

It's been my understanding that Right & Left functions return a value based on the conditions specified - I didn't know you could use them to set a value (as in append the leading zeros in this case). I would've thought that if you had a contractAmt of $400,034 for example, that the right function as you provided wouldn't append the leading zeroes.

See...this is why I'm small potatoes compared to some here. Queue is a big spud.

grin.gif

Posted

Well, I've been called worse. wink.gif

Incidentally, I don't think the NumToText is necessary either, but I could be mistaken.

This topic is 7654 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.